...

View Full Version : Need help on a drop down menu



Doggonit
06-14-2005, 10:18 PM
I am fairly new to scripting, JavaScript, heck, I will admit it, coding of any sort.

So, I am trying to make a dropdown menu that will generate at demand an empty frame, or two frames of various forms.

I pieced together the following:


<html>
<head>
<script type="text/javascript">
function go(form)
{
location=form.selectmenu.value
}
</script>
</head>

<body>
<form>
<select name="selectmenu" onchange="switchframes()">
<iframe src="frameEmpty.htm" id="frame1">Empty</iframe>
<iframe src="frameSBA.htm" id="frame2">SBA</iframe>
<iframe src="frameStructuredBond.htm" id="frame3">Structured Bond</iframe>
</select>
</form>
</body>

</html>

What is wrong here? Sorry if it is obvious, but I am really new to this and don't have a single clue as to what the problem could be.

nikkiH
06-15-2005, 02:33 PM
Before you start with javascript, you need to learn HTML.
An IFRAME is not a valid child of a SELECT element.
If you're trying to make a new element, you need createElement and appendChild. (see the LI example here http://www.codingforums.com/showthread.php?t=61293, which was posted right by your post on this page last I checked)
You'd have the options in the select and then have the onchange of the select create the new element and append it to the document.

Valid HTML becomes more important as you use javascript to manipulate the elements.
You can see the HTML specs here (http://www.w3.org/TR/html4/)

HTH

Doggonit
06-20-2005, 04:46 PM
Pardon me but this is not really a matter of learning simple HTML, this is WAY beyond simple HTML, so don't give me the admonishing schoolteacher attitude. W3 School's tutorials are useless...

nikkiH
06-21-2005, 12:37 AM
If you already knew HTML, you would have already known that iframes are not valid children of selects.
Pardon me for trying to help.
Have a nice day.

Doggonit
06-22-2005, 05:24 PM
If you already knew HTML, you would have already known that iframes are not valid children of selects.
Pardon me for trying to help.
Have a nice day.

I said simple HTML. iframes are not basic or simple for that matter.

martin_narg
06-22-2005, 06:40 PM
Is this something like what you are trying to do mate?



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Iframe menu</title>
<script>
function doMenu(strLocation) {
if( strLocation.length > 0 ) {
document.getElementById("frmIframe").src = strLocation;
}
}
</script>
</head>

<body>
<form name="frm">
<select name="selMenu" onchange="doMenu(this.value)">
<option value="" selected>Please select a link</option>
<option value="http://www.codingforums.com">Coding Forums</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
<option value="myPage.html">Another page</option>
</select>
</form>

<iframe id="frmIframe" name="frmIframe" width="400" height="200" frameborder="1"></iframe>
</body>
</html>


Hope this helps.

m_n



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum