SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    Omaha, NE
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How do you get the text out of a drop down box?

    Is there a way access the display text of a dropdown box in javascript? I can get the value of the dropdown, but I need to use the display text in the confirm portion of the javscript. Any ideas? I tried selectform.Player.text, but that gives me an undefined error, the code works with selectform.Player.value

    thanks!

    Code:
    <script language="JavaScript">
    	function VerifySelect(selectform) 
    	{ 
    	  textvalue = "Are you sure you want to select: " + selectform.Player.text;
    	  if (confirm(textvalue))
    	  {
    	  	selectform.submit();
    	  } 
    	}
    </script>

  2. #2
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    Omaha, NE
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Got it!!!!!

    I did some more searching and some trial and error and got it! it doesn't seem very clean, but it works!!!

    Code:
    <script language="JavaScript">
    	function VerifySelect(selectform) 
    	{ 
    	  textvalue = "Are you sure you want to select: " + selectform.Player.options[selectform.Player.options.selectedIndex].text;
    	  if (confirm(textvalue))
    	  {
    	  	selectform.submit();
    	  } 
    	}
    </script>

    This site really helped!

    http://www.javascriptkit.com/javatutors/combos4.shtml


Bookmarks

Posting Permissions

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