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!

Cant figure out this problem

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
I get this Error

[red]Runtime Error : Line 85 Object doesnt support this property or method[/red]

this is the line I get the error on.

Code:
cohort_year = document.TheForm.cohort_year.substring(0,cohortcheck)+ "%26" + document.TheForm.cohort_year.substring(cohortcheck+1,cohort_year.length);


TheForm is a Form, cohort_year is a <select...> box

anyone have any clue. [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
I think you problem is that you are using the same name for you variable as your form name.

try this:

cohortYear = document.TheForm.cohort_year.substring(0,cohortcheck)+ &quot;%26&quot; + document.TheForm.cohortYear.substring(cohortcheck+1,cohortYear.length);

[sig]<p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.[/sig]
 
I think you're trying to use 'substring' on a non-text object. You need to identify the selected option within the select box, and the associated value:-

Code:
if (document.TheForm.cohort_year.options[i].selected) 
{
cohortYear = document.TheForm.cohort_year.options[i].text.substring(0,cohortcheck)+ &quot;%26&quot; + document.TheForm.cohortYear.options[i].text.substring(cohortcheck+1,document.TheForm.cohortYear.options[i].text.length);
}

HTH :) [sig][/sig]
 
I figured that out right before leaving work fatbloke, oh also it's selected, not &quot;selectedindex&quot;? cuz that might be another problem. [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top