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

Javascript works in FireFox but NOT in IE

Status
Not open for further replies.

bob1660

MIS
Jul 14, 2007
6
ZA
Can someone PLEASE HELP. The Javascript works perfectly in FF but not in IE.

CODE

<!DOCTYPE HTML PUBlIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<title>NAC Memeber No. Search</title>
<style type="text/css">
.hide { display:none; }
</style>
<script type="text/javascript">
function populate(inForm)
{
var temp=0;
var today= new Date();
var day= today.getDate();
var month= today.getMonth();
var year= today.getFullYear();

t2 = 50;
for (var i=0; i <31 ; i++)
{
var x= String(i+1);
inForm.day.options = new Option(x,x);
}

for (var i=0; i <31 ; i++)
{
var d=0;
d=inForm.day.options.value;
if(d==day)
{
inForm.day.options.selected=true;
break;
}
}

for (var i=0,j=year; i <t2 ; i++, j--)
{
var y= String(j);
inForm.year.options = new Option(y,y);
}

for(var i=0;i<12;i++)
{
if(i==month)
{
inForm.month.options.selected=true;
break;
}
}
}

function populate2(inForm2)
{
var t3=0;

if (inForm2.month.options[1].selected)
t3=28;
else if(inForm2.month.options[8].selected || inForm2.month.options[3].selected || inForm2.month.options[5].selected || inForm2.month.options[10].selected)
t3=30;
else
t3=31;

for(i=0;i<31;i++)
{
inForm2.day.options=null;
}

for (var i=0; i <t3 ; i++)
{
var x= String(i+1);
inForm2.day.options = new Option(x);
}
}
</script>
<style type="text/css">
<!--
.style1 {
color: #000099;
font-weight: bold;
}
.style2 {color: #FF0000}
-->
</style>
</head>
<body onLoad=populate(document["form1"])>

<div align="center" class="style1">
<div align="center">NAC Member Number Search</div>
</div>
<br>
<div align="left">Select your Date of Birth below and enter your First Name and Last Name to search for your NAC Member No.</div>
<form name='form1' action='process_form.php' method='POST'>
<table class='table_form_1' id='table_form_1' cellspacing='0'>
<tr>
<p>
<b>Year</b><SELECT NAME="year"></SELECT>

<b>Month</b> <SELECT NAME="month" onChange = populate2(form1)>
<Option value=1>01</Option>
<Option value=2>02</Option>
<Option value=3>03</Option>
<Option value=4>04</Option>
<Option value=5>05</Option>
<Option value=6>06</Option>
<Option value=7>07</Option>
<Option value=8>08</Option>
<Option value=9>09</Option>
<Option value=10>10</Option>
<Option value=11>11</Option>
<Option value=12>12</Option>
</SELECT>

<b>Day</b> <SELECT NAME="day"></SELECT>

</FORM>

</td>
</tr>
<tr>
<td class='ftbl_row_2' ><LABEL for='firstName' ACCESSKEY='none' ><b style='color:red'>*</b>First Name
</td>
<td class='ftbl_row_2a' ><input type='text' name='firstName' id='firstName' size='20' value=''>
</td>
</tr>
<tr>
<td class='ftbl_row_1' ><LABEL for='lastName' ACCESSKEY='none' ><b style='color:red'>*</b>Last Name
</td>
<td class='ftbl_row_1a' ><input type='text' name='lastName' id='lastName' size='45' value=''>
</td>
</tr>
<tr>
<td colspan='2' align='right'><input type='submit' name='submit' value='Submit'>&nbsp;<input type='reset' name='reset' value='Reset'><br /><a</a>
</td>
</tr>
</table>
</form>

</body>
</html>
 
Try this:
Code:
<body onLoad=[!]"[/!]populate(document[[!]'[/!]form1[!]'[/!]])[!]"[/!]>

Also... check that the page validates (URLs in my .sig) - to help you debug it better.

Cheers,
Jeff


[tt]Jeff's Page [!]@[/!] Code Couch
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Spotted another one as well...
Code:
<select name="month" onchange=[!]"populate2(this.form)"[/!]>
Cheers,
Jeff


[tt]Jeff's Page [!]@[/!] Code Couch
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
A suggestion to help improve HTML coding style going forward away from "loose" structured documents: use lower case for your HTML element names. This will mean you can code XHTML and XML without a problem. It's also a bit more readable when you have a lot of it to get through :)

ie: <select> not <SELECT> or <option> not <Option>

Just a suggestion [smile]

Cheers,
Jeff


[tt]Jeff's Page [!]@[/!] Code Couch
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Perhaps then, you can give more details about how it "does not work" because you've not told us anything so far.

Assuming you're talking about the "number of days" dropdown being populated with the correct number when the month changes, the original code you posted works for me as-is in IE 6 and Fx 2.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Sorry Dan,

I should have explained that the submit and reset buttons works in FF and not in IE. With FF you can reset entries, and the submit button fires off the process_form.php script. IE however does nothing on both buttons.

Hope this helps
 
It would be useful for those following this thread (now and in the future) to have some more useful feedback than "Problem resolved"! Could you describe the solution that resolved this problem for future generations?

Cheers,
Jeff


[tt]Jeff's Page [!]@[/!] Code Couch
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top