Results 1 to 4 of 4

Thread: Javascript

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Question

    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>

  2. #2
    Guest

    Cool 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,
    Mac

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Talking

    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

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Turf

    I just hooked you up on this one, go here
    http://www.vbforums.com/showthread.php?threadid=48229

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width