Forum Moderators: open

Message Too Old, No Replies

Forms and popup windows...

         

GWJ

3:12 pm on Feb 27, 2002 (gmt 0)



Hi,

I have been asked to create a form listing around 30 options per form and need 10 forms, no problem. They however when an option is selected want it to generate a popup window instead of just going to the page. I can not seem to figure this one out after playing with it.

Here is my form code (ripped out all URLS and made gibberish)...

<form name="north">
<div align="center"><center><select NAME="reference" SIZE="1" onChange="goto_url(this)">
<option SELECTED>Northern Region</option>
<option VALUE="whatever/index.htm">North office</option>
<option VALUE="whatever2/index.htm">North office two</option>
<option VALUE="whatever3/index.htm">North office 3</option>
</select>
</center></div>
</form>

I tried using several popup windows scripts in combination with the value="" but it just goes to whatever/<a%20href=

I have no issues with forms, I have no issues with popup windows setup. Any suggestions on how to combine the two?

TIA,

Brian

txbakers

3:54 pm on Feb 27, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



what if you use the OnChange method to fire off a function which reads the value of the dropdown, then use the window.open command to open that value?

It shouldn't be difficult.

GWJ

5:04 pm on Feb 27, 2002 (gmt 0)



Hi,

Thank you for the quick response. I hate to say it but could you show me what you mean. I am afraid I do not understand how to go about that.

Brian

jatar_k

7:07 pm on Feb 27, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



maybe try something like this

your onChange just calls the function

onChange="openPopup();"

function openPopup(){
popupurl="http://www.yourdomain.com/"+document.formname.formelement.options[document.formname.formelement.selectedIndex].value;
newwindow = window.open(popupurl, "windowname", "height=600,width=400,resizable=yes,scrollbars=yes");
newwindow.focus();
}

I just threw in some attributes for the new window, I didn't test this either but the premise is basically right

GWJ

12:13 pm on Feb 28, 2002 (gmt 0)



Thank you I will give it a wirl. I really appreciate it jatar_k.

Brian

GWJ

2:32 pm on Feb 28, 2002 (gmt 0)



Hi,

I seem to be getting an error on the JS...
"openPopup is not defined".

This is what I have...

<form name="north">
<div align="center"><center><select NAME="reference" SIZE="1" onChange="openPopup();"

function openPopup(){
popupurl="http://www.yourdomain.com/"+document.formname.formelement.options[document.formname.formelement.selectedIndex].value;

newwindow = window.open(popupurl, "windowname", "height=600,width=400,resizable=yes,scrollbars=yes");
newwindow.focus();
} >
<option SELECTED>Northern Region</option>
<option VALUE="none"></option>
<option VALUE="whatever/index.htm">Where</option>
<option VALUE="whatever/index.htm">Where 2</option>
</select>
</center></div>
</form>

Sorry to be soooo lost on this but I really want to make this work,

Brian

Chameleon

10:52 am on Mar 6, 2002 (gmt 0)

10+ Year Member



Try putting the js inside the <head> tags and enclose the script in script tags.

Reflect

1:03 pm on Mar 8, 2002 (gmt 0)

10+ Year Member



Hi,

Thanks. I worked this out yesterday. Have it with a go button and without a go button.

Thanks for all of the help,

Brian