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

expected Identifier error. Can you help.

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I am getting an expected identifier with my script and was wondering if someone could tell me what is wrong with it?

function checkit()
{
tf='15' //number of text fields (tf)
num='0' //set your counter value to zero

for (k=1;k<=tf;k++) { //start reading the text boxes

x=eval(&quot;document.form1.date&quot;+k+&quot;.value&quot;) //give x the value of a text box, based on the value of k

if (x!='') {num++;} //if it is not empty, add 1
}
for(var i=1;i<num;i++) {
var theDate = document.form1.[&quot;hour&quot; + i].value;
var dateArr = theDate.split(&quot;/&quot;)

checkstr = document.form1.hidden1.value;
if (checkstr != dateArr[0])
{
alert ('your months do not match');
return false;
}
}
}
 
You have to refer to an element with [&quot;hour&quot; + i]

var theDate = document.form1.[&quot;hour&quot; + i].value;

should be

var theDate = document.form1.elements[&quot;hour&quot; + i].value;
 

try this line:

var theDate = eval(&quot;document.form1.[hour&quot;+i+&quot;].value&quot;;

tell me what happens, or post the code in its entirety so it can be tested...


- spewn
 

sorry...

var theDate = eval(&quot;document.form1.[hour&quot;+i+&quot;].value&quot;);

forgot the ending )


- spewn
 
You have to refer to an element with [&quot;hour&quot; + i]

var theDate = document.form1.[&quot;hour&quot; + i].value;

should be

var theDate = document.form1.elements[&quot;hour&quot; + i].value;
 
Okay I had one thing screwed up. It should have been date not hour. I have no errors but the script is still not working. Basically if someone selects a month from my dropdown menu the first 2 numbers of the text box must match that value. Here is the complete page.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top