venukalikota
asked on
Display Image on a condition
Hello
I have some scanned signature images in a folder. My Asp Page has a Selection Box with some names.I want to display the scanned signature image in the ASP page depending on the user selecting the name.Also can I submit that image to another page through a form?
Thanks
Venu
I have some scanned signature images in a folder. My Asp Page has a Selection Box with some names.I want to display the scanned signature image in the ASP page depending on the user selecting the name.Also can I submit that image to another page through a form?
Thanks
Venu
ASKER
MrClean21
Do you know how to do this in VbScript? If i use the above code iam getting the error "Object does not support this property or method" when I select a name from the select box
Do you know how to do this in VbScript? If i use the above code iam getting the error "Object does not support this property or method" when I select a name from the select box
Sorry,
Here's the good one..
function changeImage(elem) {
sign = document.getElementById("s ignature") ;
sign.src = "http://www.com/images/" + elem.value + ".jpg";
}
in VBScript, it looks like this :
function changeImage(elem)
sign = document.getElementById("s ignature") ;
sign.src = "http://www.com/images/" + elem.value + ".jpg";
end function
Here's the good one..
function changeImage(elem) {
sign = document.getElementById("s
sign.src = "http://www.com/images/" + elem.value + ".jpg";
}
in VBScript, it looks like this :
function changeImage(elem)
sign = document.getElementById("s
sign.src = "http://www.com/images/" + elem.value + ".jpg";
end function
ASKER
Gives the error
Char: 2
Error: Object does n't support this property or method: 'elem.value'
code: 0
Further help would be appreciated
Thanks
Char: 2
Error: Object does n't support this property or method: 'elem.value'
code: 0
Further help would be appreciated
Thanks
venukalikota,
using vbscript, you should reference the function like
<select id='Name' onchange='changeImage(me)' >
function changeImage(elem)
set sign = document.getElementById("s ignature")
sign.src = "http://www.com/images/" + elem.value + ".jpg"
end function
with an image with an id of signature like :
<img id="signature" src="blank.jpg">
using vbscript, you should reference the function like
<select id='Name' onchange='changeImage(me)'
function changeImage(elem)
set sign = document.getElementById("s
sign.src = "http://www.com/images/" + elem.value + ".jpg"
end function
with an image with an id of signature like :
<img id="signature" src="blank.jpg">
ASKER
Image tag has the id ="signature". That does n't work
here's the complete test page that works for me :
<html>
<body>
<script language="vbscript">
function test(elem)
msgbox elem.value
set sign = document.getElementById("s ignature")
sign.src = "http://www.com/images/" + elem.value + ".jpg"
end function
</script>
<select id="sel" onchange="test(me)">
<option></option>
<option value="1">1</option>
<option value="2">3</option>
<option value="3">4</option>
</select>
<img id="signature" src="">
</body>
</html>
<html>
<body>
<script language="vbscript">
function test(elem)
msgbox elem.value
set sign = document.getElementById("s
sign.src = "http://www.com/images/" + elem.value + ".jpg"
end function
</script>
<select id="sel" onchange="test(me)">
<option></option>
<option value="1">1</option>
<option value="2">3</option>
<option value="3">4</option>
</select>
<img id="signature" src="">
</body>
</html>
ASKER
My code looks like this and does not seem to work. Getting Type Mismatch error.it will not display the msgbox. If i remove the signature it gives the error "object required: 'sign' ". I have also tried using elem.value. It gives the error "object does not support this method or property: 'elem.value'
<%
Function getSupName()
rs.Open cn.Execute("SELECT RFullName, RFirst, RLast FROM Resources WHERE RInactive = 0 AND (InstSup = 1) AND (EntityCode = 'SE')ORDER BY RFullName")
image = CStr(rs.Fields("RLast"))
Response.Write("<select id=InstSupName name=InstSupName onchange='changeImage(imag e)' title='Select Supervisor' style='FONT-FAMILY: verdana'>")
Do Until rs.EOF
Response.Write("<option value='" & rs.Fields("RFullName") & "'>" & rs.Fields("RFullName") & "</option>")
rs.moveNext
Loop
Response.Write("</select>" )
End Function
%>
<html>
<head>
<script ID="clientEventHandlersVBS " LANGUAGE="vbscript">
<!--
Function changeImage(elem)
msgbox elem
sign = document.getElementById("s ignature")
sign.src = "../ASP/" + elem + ".bmp"
End Function
-->
</script>
</head>
<form id="FORM1" method="post" name="FORM1">
<body>
<table align="center" border="0" cellPadding="1" cellSpacing="1" width="100%" height="25%" valign="center" background tabIndex="0" >
<tr>
<td colSpan="2">
<p align="left"> & nbsp;  ; Installation REP:
<%=getSupName()%>
</p><td colSpan="2">
<img id="signature" name="signature" src="../ASP/Chris.bmp" height=50 width=200>
</td>
</tr>
</table>
</body>
</form>
</html>
<%
Function getSupName()
rs.Open cn.Execute("SELECT RFullName, RFirst, RLast FROM Resources WHERE RInactive = 0 AND (InstSup = 1) AND (EntityCode = 'SE')ORDER BY RFullName")
image = CStr(rs.Fields("RLast"))
Response.Write("<select id=InstSupName name=InstSupName onchange='changeImage(imag
Do Until rs.EOF
Response.Write("<option value='" & rs.Fields("RFullName") & "'>" & rs.Fields("RFullName") & "</option>")
rs.moveNext
Loop
Response.Write("</select>"
End Function
%>
<html>
<head>
<script ID="clientEventHandlersVBS
<!--
Function changeImage(elem)
msgbox elem
sign = document.getElementById("s
sign.src = "../ASP/" + elem + ".bmp"
End Function
-->
</script>
</head>
<form id="FORM1" method="post" name="FORM1">
<body>
<table align="center" border="0" cellPadding="1" cellSpacing="1" width="100%" height="25%" valign="center" background tabIndex="0" >
<tr>
<td colSpan="2">
<p align="left"> &
<%=getSupName()%>
</p><td colSpan="2">
<img id="signature" name="signature" src="../ASP/Chris.bmp" height=50 width=200>
</td>
</tr>
</table>
</body>
</form>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I changed the code the msgbox displays correctly but
Still gives the error "Object Required: 'sign' ". I think it is some how not considering the signature as an object on the form.
Still gives the error "Object Required: 'sign' ". I think it is some how not considering the signature as an object on the form.
This works fine
<%
strConn = "Provider=SQLOLEDB; "
strConn = strConn & "Data Source=Atlas; "
strConn = strConn & "Initial Catalog=tms; "
strConn = strConn & "User Id=leaveuser; "
strConn = strConn & "Password=userleave"
set cn = server.createobject("adodb .connectio n")
set objRs = server.createobject("adodb .connectio n")
Function getSupName()
cn.open strConn
strSql = "SELECT RFullName, RFirst, RLast FROM Resources WHERE RInactive = 0 AND (InstSup = 1) AND (EntityCode = 'SE') ORDER BY RFullName"
set objRs = cn.Execute(strSql)
' image = CStr(objRs.Fields("RLast") )
Response.Write("<select id=InstSupName name=InstSupName onchange='changeImage(this )' title='Select Supervisor' style='FONT-FAMILY: verdana'>")
Do Until objRs.EOF
Response.Write("<option value='" & objRs.Fields("RFullName") & "'>" & objRs.Fields("RFullName") & "</option>")
objRs.moveNext
Loop
Response.Write("</select>" )
End Function
%>
<html>
<head>
<script LANGUAGE="javascript">
<!--
function changeImage(imgName)
{
if (document.images)
{
document['signature'].src= "../ASP/" + imgName.value + ".gif";
}
}
//-->
</script>
</head>
<form id="FORM1" method="post" name="FORM1">
<body>
<table align="center" border="0" cellPadding="1" cellSpacing="1" width="100%" height="25%" valign="center" background tabIndex="0" >
<tr>
<td colSpan="2">
<p align="left"> & nbsp;  ; Installation REP:
<%=getSupName()%>
</p><td colSpan="2">
<img id="signature" name="signature" src="../ASP/Chris.bmp" height=50 width=200>
</td>
</tr>
</table>
</body>
</form>
</html>
<%
strConn = "Provider=SQLOLEDB; "
strConn = strConn & "Data Source=Atlas; "
strConn = strConn & "Initial Catalog=tms; "
strConn = strConn & "User Id=leaveuser; "
strConn = strConn & "Password=userleave"
set cn = server.createobject("adodb
set objRs = server.createobject("adodb
Function getSupName()
cn.open strConn
strSql = "SELECT RFullName, RFirst, RLast FROM Resources WHERE RInactive = 0 AND (InstSup = 1) AND (EntityCode = 'SE') ORDER BY RFullName"
set objRs = cn.Execute(strSql)
' image = CStr(objRs.Fields("RLast")
Response.Write("<select id=InstSupName name=InstSupName onchange='changeImage(this
Do Until objRs.EOF
Response.Write("<option value='" & objRs.Fields("RFullName") & "'>" & objRs.Fields("RFullName") & "</option>")
objRs.moveNext
Loop
Response.Write("</select>"
End Function
%>
<html>
<head>
<script LANGUAGE="javascript">
<!--
function changeImage(imgName)
{
if (document.images)
{
document['signature'].src=
}
}
//-->
</script>
</head>
<form id="FORM1" method="post" name="FORM1">
<body>
<table align="center" border="0" cellPadding="1" cellSpacing="1" width="100%" height="25%" valign="center" background tabIndex="0" >
<tr>
<td colSpan="2">
<p align="left"> &
<%=getSupName()%>
</p><td colSpan="2">
<img id="signature" name="signature" src="../ASP/Chris.bmp" height=50 width=200>
</td>
</tr>
</table>
</body>
</form>
</html>
Since the sign is the object of the image tag, you must use set :
set sign = document.getElementById("s ignature")
sign.src = "../ASP/" + elem + ".bmp"
MrClean
set sign = document.getElementById("s
sign.src = "../ASP/" + elem + ".bmp"
MrClean
ASKER
Thank you very much MrClean. Works everything fine now. I appreciate your great help.
It's been a pleasure to help you.
You can do it with javascript like :
<select id='Name' onchange='changeImage(this
...
</select>
<script>
function changeImage(elem) {
sign = document.getElementById("s
sign.src = "http://www.com/images/" + elem.value() + ".jpg";
}
</script>
To pass the value to another page, just set the value of an hidden field to the selected name.
MrClean