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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOM's Option object Error 1

Status
Not open for further replies.

arlequin

Programmer
Sep 21, 1999
232
UY
Hi people!<br><br>Does anyone know why this codelines show me <br>&quot;Options is not an object&quot; ?<br><br><br>function validatecard() <br>{<br>var doc = document.forms[0].instfin;<br><br>var combo = doc.options[doc.selectedIndex].text<br>var combovalue = doc.value<br><br>if (document.forms[0].Ent1.value == &quot;&quot;)<br>.....<br>.....<br><br>THANX&nbsp;&nbsp;&nbsp;:)
 
Hard to tell without the rest of the code/HTML.&nbsp;&nbsp;A couple of things come to mind.&nbsp;&nbsp;As I'm sure you know, the basic structure is:<br><br>var variable=document.forms['formname'].elements['elementname'];<br><br>variable.options[0]=something;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-or-<br>variable2=variable.options[0];<br><br>In your code, is instfin the name of a UNIQUE form element or is it the name of a group.&nbsp;&nbsp;If name of group, it should be instfin[0] or whatever.&nbsp;&nbsp;Is doc.selectindex a UNIQUE element?&nbsp;&nbsp;If they are, I don't see anything wrong.<br><br>How do you call the function.&nbsp;&nbsp;If it's called prior to the page loading fully, you will get an error.&nbsp;&nbsp;I assume this is not the case.<br><br>Where did you define options?&nbsp;&nbsp;Is it an HTML option in a select box that already exists, or are you trying to add a new option on the fly, in which case it may not yet exist.<br><br><br>I hate problems like this.&nbsp;&nbsp;It's so frustrating to see a piece of code that looks perfectly logical but you have a 'dumb' machine telling you it's not.&nbsp;&nbsp;Good Luck!<br><br>Russ<br>
 
Finally I found the answer to my own question...&nbsp;&nbsp;:)<br>LOL<br><br>I was refering to a form in this way: document.forms[0]<br>but it wasn't the UNIQUE form in the whole HTML page...<br>It's is common when working wiht includes or JS files to have a lot of forms or instead of that, more than one...<br><br>So, when I refered to the form by the NAME, all the problems went out from my script!!<br><br>Anyway, MANY THANX to Russ and everyone that tryed to help me! You R a great team! Never give up!!<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top