Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Expected

Status
Not open for further replies.

gbaughma

IS-IT--Management
Staff member
Nov 21, 2003
4,772
US
Stupid *&@(#*&$@# script.

All I want it to do is change the values of the drop-down, depending on which radio button is selected.

Here's a snippet.....

Code:
<html>
<head>

<script LANGUAGE='Javascript'>
function dropdown()
{
var objSelect = document.form1.Days;
while(objSelect.options.length > 1){objSelect.remove(1);}
if (document.form1.thelog[0].checked = true){
	document.form1.Days.options = new Option ("All",99999);
	document.form1.Days.options = new Option("1",1);
	document.form1.Days.options = new Option("2",2);
	document.form1.Days.options = new Option("3",3);
	document.form1.Days.options = new Option("4",4);
	document.form1.Days.options = new Option("7",7);
	document.form1.Days.options = new Option("14",14);
	} Else {
	document.form1.Days.options = new Option("All",99999);
	document.form1.Days.options = new Option("90",90);
	document.form1.Days.options = new Option("180",180);
	document.form1.Days.options = new Option("1 year",365);
	document.form1.Days.options = new Option("2 years",730);
	}
}

</script>
</head>
<html>
. . . etc

(and in a form)
<input type="Radio" Name="thelog" value="1" onClick="dropdown();" CHECKED>
Current Logs&nbsp;
<input type="Radio" Name="thelog" value="2" onClick="dropdown();">
Archived Logs
&nbsp;<font size=-1>(Note: Selection archived logs may take a long time!  Over 1 million records...)</font>
</td></tr>
<tr>
<td>For how many days?</td><td> <select name="Days" size="1">
	  <option Selected value="99999">All</option>
	  <option value="1">1</option>
	  <option value="2">2</option>
	  <option value="3">3</option>
	  <option value="4">4</option>
	  <option>7</option>
  	  <option>14</option>
	  <option>30</option>
	  <option>60</option>
	  </select> Days  <font size=-1><--- Current logs only go back 90 days.</font>

... and so forth

... but, when I change the radio button, which should fire the onClick="dropdown();" bit, it errors, and says Object Expected on the line that has the radio button.

<grumble>

Any thoughts about what I'm doing wrong? It's probably something obvious that I've overlooked....



Just my 2¢
-Cole's Law: Shredded cabbage

--Greg
 
objSelect.options starts counting from zero rather than one.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Webflo
 
You can change this
Code:
while(objSelect.options.length > 1){objSelect.remove(1);}
To this
Code:
objSelect.options.length = 0;
You're right about capitalizing the else, it needs to be lowercase

And this also needs changed:
Code:
if (document.form1.thelog[0].checked =[!]=[/!] true){
Or even better, get rid of the reference to true altogether, it's not needed. When you make a reference to the checked value for that element it returns a boolean value, which is what the if statement is looking for anyway:
Code:
if (document.form1.thelog[0].checked){
What you were doing before was setting the value of the radio button to checked every time.

Remember in javascript one equals sign (=) is the assignment operator, and two equals signs (==) is the comparison operator.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
  • Thread starter
  • Moderator
  • #6
got it working.... had to oil up my brain gears a little.... lol



Just my 2¢
-Cole's Law: Shredded cabbage

--Greg
 
Glad I could be of [purple]help[/purple] [smile]

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top