...

View Full Version : Jump Menu OnChange Command Problem



Massham1
01-15-2003, 11:43 PM
I have a jump menu that I would like to user for url's & html pages. However, it keeps giving me an "object required" error message. I have success when I use a go button, but can't get the "OnChange" command to work. I don't want to use a go, or submit button. I have searched my JavaScript bible to help me, but can't fine the solution. Help Please :)

CRASH_OVERRIDE
01-15-2003, 11:53 PM
I would have to see the code, but 'Object Required' commonly means that you:
- Havent specified an object to get the method from;
- Have mistyped the object or method name;
- Are specifying a object or method that doesnt exist;
- Other possibilities...

Im pretty sure thats right, this is based on my experience, but spare me if im wrong. :cool:

Massham1
01-16-2003, 12:22 AM
Mr. Crash:

Thank you for your expedient response! Please see the following scrpt:

Header:

<script language="JavaScript">
<!--
function gotoLink(form) {
var OptionIndex=form.ListBoxURL.selectedIndex;
parent.location = form.ListBoxURL.options[OptionIndex].value;}
//-->
</script>

Body:

<select name="ListBoxURL" size="1" language="javascript" onchange="gotoLink(this.form);">
<option value="http:\\www.irwin.army.mil\default.htm">Test</option>
<option value="URL #2.htm">Place 2 </option>
<option value="URL#3.htm">Place 3 </option>
<option selected> -- Select to Jump -- </option>
</select>

arnyinc
01-16-2003, 01:03 AM
Is your <select> box within a <form> ?



<html>
<head>
<script language="JavaScript">
<!--
function gotoLink(form) {
var OptionIndex=form.ListBoxURL.selectedIndex;
parent.location=form.ListBoxURL.options[OptionIndex].value;
}
//-->
</script>
</head>

<body>
<form name="myform">
<select name="ListBoxURL" onchange="gotoLink(this.form);">
<option value="http://www.irwin.army.mil/default.htm">Test</option>
<option value="URL2.htm">Place 2 </option>
<option value="URL3.htm">Place 3 </option>
<option selected> -- Select to Jump -- </option>
</form>
</select>
</body>

</html>

Massham1
01-16-2003, 01:33 AM
I may be confused about what a form refers to. However, I do believe I am using one based on this:::

I have a drop-down menu; I believe this is what is considered a form. I am using FrontPage to edit and a drop-down is referred to as a form in this arena.

I am sorry about my confusion; I am very new to JS and web development. I have figured out a lot of stuff, but I am stuck on this one.

I appreciate your assistance.

arnyinc
01-16-2003, 04:32 AM
I am referring to the part of your code where you have:

Body:


<select name="ListBoxURL" size="1" language="javascript" onchange="gotoLink(this.form);">
<option value="http:\\www.irwin.army.mil\default.htm">Test</option>
<option value="URL #2.htm">Place 2 </option>
<option value="URL#3.htm">Place 3 </option>
<option selected> -- Select to Jump -- </option>
</select>


it should be: (note the addition of the first and last lines)



<form name="myform">
<select name="ListBoxURL" onchange="gotoLink(this.form);">
<option value="http://www.irwin.army.mil/default.htm">Test</option>
<option value="URL2.htm">Place 2 </option>
<option value="URL3.htm">Place 3 </option>
<option selected> -- Select to Jump -- </option>
</select>
</form>

cg9com
01-16-2003, 06:23 AM
http://www.codingforums.com/showthread.php?s=&threadid=13046

Massham1
01-16-2003, 06:07 PM
Arnyinc/Crash

Thank you for your help. Arnyinc, I was missing the form tag; it works like a champ.

many thanks!

massham1



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum