Connecting Tech Pros Worldwide Forums | Help | Site Map

Select value and window popUp

Familiar Sight
 
Join Date: Oct 2007
Posts: 254
#1: Aug 18 '08
Hello.

It's possible at this select when you select only the value BBB automatically open a web page in the window popUp ?

Expand|Select|Wrap|Line Numbers
  1. <form method="POST" action="next.asp">
  2.   <p>
  3.   <select size="1" name="D1">
  4.   <option>Select</option>
  5.   <option value="AAA">AAA</option>
  6.   <option value="BBB">BBB</option>
  7.   </select>
  8.  
  9.   <input type="submit" value="GO" name="B1">
  10.   <input type="reset" value="RESET" name="B2">
  11.   </p>
  12.  
  13. </form>

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Aug 19 '08

re: Select value and window popUp


Yes, you can call a function onchange which checks the value of selected. If it's "BBB", open a pop up window using window.open().
Familiar Sight
 
Join Date: Oct 2007
Posts: 254
#3: Aug 19 '08

re: Select value and window popUp


thanks x your answer.

I write this code and working... its right?

Expand|Select|Wrap|Line Numbers
  1. <select size="1" name="D1" onchange="if(this.value=='BBB')window.open('http://myurl.com');">
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Aug 19 '08

re: Select value and window popUp


Yes, that should work. If you're later planning to have more than one line of code, it would be better in a function. Anyway, a good job on figuring it out yourself :)
Reply