-
Hi,
Someone gave me this code which is executed when the submit button is clicked. As you can see I have a dropdown menu called "lstcountry "which is filled with Country names.
How can I change this code to return the TEXT VALUE of what was selected and NOT the index/no.
As it is now, it returns "1" when AUSTRALIA is selected, but I want it to return "AUSTRALIA".
Another question is..
what is the equivalent of response.write in javascript. Reason for asking is because I want to debug this code so when it enters this I want it to do a response.write lstcountry, but the javascript equivalent of that!!
<head><script language="javascript">
function redirectpage()
{
if(document.frmcountry.lstcountry.options[document.frmcountry.lstcountry.selectedIndex].value == 0)
{
document.frmcountry.action = "city.asp";
document.frmcountry.submit();
}
else
{
document.frmcountry.submit();
}
}
</script>
-
Try this
Hi...try this....:)
<HTML>
<HEAD><TITLE></TITLE>
<Script Language="JScript">
<!--
function testing()
{
alert(document.form1.select1.value)
document.write(document.form1.select1.value)
}
//-->
</Script>
</HEAD>
<BODY>
<Form name="form1">
<P><SELECT id=select1 name=SELECTED onChange="testing()">
<OPTION value="text1">value 1</OPTION>
<OPTION value="text2">value 2</OPTION>
<OPTION value="text3">value 3</OPTION>
<OPTION value="text4">value 4</OPTION>
</SELECT></P>
</form></BODY></HTML>
U can use
document.write is same as response.write in ASP
document.write("Hello") in JScript
response.write "Hello" in ASP
regards,
:o Mac :)
-
Hi Mac,
This looks like what I need. The alert however brings up a MSGBOX with the name of the country selected.
So at least I know that it does actually know what COUNTRY I selected. How can I now populate a variable with that text ie. instead of bringing up the MSGBOX, populate a variable on which I will then do some "if then else" tests!!
Thanks very much for your help.
T
-