...

View Full Version : How would I make this page example functional?



Lodestonetx
01-08-2007, 01:04 AM
An example of a page I'm trying to make can be found here:

http://homepage.mac.com/jkrivoshein/js/index.html

Its not an addition thing, the numbers are just variables. Basically, I want to be able to select two different drop down menus, then, click on the Submit button which will launch a small pop up window with the result of what would happen where two separate numbers are choosen.

I have no idea where to start :(

Does anyone have an idea of what I should start reading to understand how to do this, or is there any example code with this sort of situation in mind?

david_kw
01-08-2007, 02:39 AM
I'm not sure I understand what you want, but try this just in case.



<html>
<head>
<script type="text/javascript">
function openNew() {
var html_src="<html><head><title>NewWin</title></head><body><div>You choose " + f1.s1.options[f1.s1.selectedIndex].value +
" and " + f2.s2.options[f2.s2.selectedIndex].value + " so there!</div></body></html>";
var popup_win=window.open('','','scrollbars=no,toolbar=no,width=300,height=200');
popup_win.document.open();
popup_win.document.write(html_src);
popup_win.document.close();
}
</script>
</head>
<body>

<center>

<TABLE BORDER=0 CELLPADDING=0>
<TR> <TD><form name="f1" action="#" onsubmit="return(false);">
<select name="s1">
<option value="select" selected="selected">Select</option>
<option value="fam">1</option>
<option value="ind">2</option>
<option value="fiat">3</option>
<option value="audi">4</option>
<option value="audi">5</option>
<option value="audi">6</option>
<option value="audi">7</option>
<option value="audi">8</option>
</select>
</form></TD>

<TD><form name="f2" action="#" onsubmit="return(false);">
<select name="s2">
<option value="select" selected="selected">Select</option>
<option value="fam">1</option>
<option value="ind">2</option>
<option value="fiat">3</option>
<option value="audi">4</option>
<option value="audi">5</option>
<option value="audi">6</option>
<option value="audi">7</option>
<option value="audi">8</option>
</select>
</form></TD>

<TD><form id="form5" name="form5" method="post" action="" onsubmit="openNew(); return(false);">
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</form></TD> </TR>
</TABLE>

</center>
</body>
</html>


david_kw

Lodestonetx
01-08-2007, 04:22 PM
Ah, that is neat, thank you for the help! Ideally, I want to create 64 separate webpages, and then have that open window function direct you to the correct one. For example, if you choose 3, then 6, and click submit, it will open a popup window displaying page 36 (which I actually haven't made yet, but that will be easy).

It seems like all i need to do is to figure out how to change the openNew() function you provided to redirect to the correct page.

david_kw
01-08-2007, 05:14 PM
It is probably something like this



window.open("http://www.site.com/page" + f1.s1.options[f1.s1.selectedIndex].text + "" + f2.s2.options[f2.s2.selectedIndex].text + ".html");


Note this is untested but the basic idea.

david_kw

Lodestonetx
01-08-2007, 05:35 PM
It is probably something like this



window.open("http://www.site.com/page" + f1.s1.options[f1.s1.selectedIndex].text + "" + f2.s2.options[f2.s2.selectedIndex].text + ".html");


Note this is untested but the basic idea.

david_kw

This looks like it will work perfectly once I get all the pages made, thank you so much!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum