Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem in fetching value from list/menu

    <html><head>
    <script language="JavaScript" type="text/javascript">
    function Fxn(){
    var temp = document.form1.category.selectedIndex;
    alert (temp);
    window.location.replace("addnewproduct.php?category=" + temp);

    }
    </script>
    </head>
    <body>
    <select name="category" id="category" onChange="Fxn(test);">
    <option value="test1">test1</>
    <option value="test2">test2</>
    <option value="test3">test3</>
    </select>
    </body>
    </html>

    problem is with bold line ,
    how can i fetch value on fxn?

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    your example code does not have a form tag....

    var sel = document.form1.category;
    var text = sel.options(sel.selectedIndex).text;
    var value = sel.options(sel.selectedIndex).value;


    see if that helps....
    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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