markerasmus
asked on
OnChange not working in IE 6
I have the following code setup on a webform:
<tr>
<td>
<label for="EmailAddress">
Email Address</label><br />
<input type="text" class="cat_textbox" id="EmailAddress" maxlength="255" name="EmailAddress"
onchange="document.getElem entById('U sername'). value=this .value;" />
</td>
</tr>
<tr class="hidden">
<td>
<label for="Username">
Username</label><br />
<input type="text" class="cat_textbox" id="Username" maxlength="255" name="Username" />
</td>
</tr>
The onchange event is not working in IE 6. Any ideas why?
<tr>
<td>
<label for="EmailAddress">
Email Address</label><br />
<input type="text" class="cat_textbox" id="EmailAddress" maxlength="255" name="EmailAddress"
onchange="document.getElem
</td>
</tr>
<tr class="hidden">
<td>
<label for="Username">
Username</label><br />
<input type="text" class="cat_textbox" id="Username" maxlength="255" name="Username" />
</td>
</tr>
The onchange event is not working in IE 6. Any ideas why?
IE 6/7 has problems in this area. Does this work in Firefox? Also make sure you don't have anything name username. Because in IE Username and username are the same.
The code above works fine for me. You may have other JavaScript errors or DOM node id clashes that occurring and preventing the code from executing properly.
Can you supply the full HTML for the page? or even better, a link?
Can you supply the full HTML for the page? or even better, a link?
ASKER
The code is working fine for me in IE7 and Firefox. Only today someone let me know it wasn't working in IE6.
ASKER
Mmm, interesting. I have checked with the user and they confirm Javascritp is enabled. Here is the whole form:
<form enctype="multipart/form-da ta" method="post" action="/FormProcessv2.asp x?WebFormI D=18180&am p;OID=1612 829&OT YPE=1& EID=0& CID=0& SAR=false"
onsubmit="return checkWholeForm32339(this)" name="catwebformform32339" >
<table cellspacing="0" cellpadding="2" border="0" class="webform">
<tbody>
<tr>
<td>
<label for="Title">
Title</label><br />
<select name="Title" id="Title" class="cat_dropdown_smalle r">
<option value=" " selected="true">-- Please select --</option>
<option value="183558">DR</option>
<option value="183557">MISS</optio n>
<option value="183554">MR</option>
<option value="183555">MRS</option >
<option value="183556">MS</option>
</select>
</td>
</tr>
<tr>
<td class="tail">
<label for="FirstName">
First Name</label><br />
<input type="text" name="FirstName" maxlength="255" id="FirstName" class="cat_textbox" /><span
class="req">•</span>
</td>
<td class="tail">
<label for="LastName">
Last Name</label><br />
<input type="text" name="LastName" maxlength="255" id="LastName" class="cat_textbox" /><span
class="req">•</span>
</td>
</tr>
<tr>
<td>
<label for="EmailAddress">
Email Address</label><br />
<input type="text" onchange="document.getElem entById('U sername'). value=this .value;"
name="EmailAddress" maxlength="255" id="EmailAddress" class="cat_textbox" /><span
class="req">•</span>
</td>
</tr>
<tr class="hidden">
<td>
<label for="Username">
Username</label><br />
<input type="text" name="Username" maxlength="255" id="Username" class="cat_textbox" /><span
class="req">•</span>
</td>
</tr>
<tr>
<td class="tail">
<label for="Password">
Password</label><br />
<input type="password" name="Password" maxlength="255" id="Password" class="cat_textbox" /><span
class="req">•</span>
</td>
<td class="tail">
<label for="PasswordConfirm">
Confirm Password</label><br />
<input type="password" name="PasswordConfirm" maxlength="255" id="PasswordConfirm"
class="cat_textbox" /><span class="req">•</span>
</td>
</tr>
<tr>
<td>
<label for="HomeAddress">
Home Address</label><br />
<input type="text" name="HomeAddress" maxlength="500" id="HomeAddress" class="cat_textbox" /><span
class="req">•</span>
</td>
<td>
<label for="HomeCity">
City</label><br />
<input type="text" name="HomeCity" maxlength="255" id="HomeCity" class="cat_textbox" /><span
class="req">•</span>
</td>
</tr>
<tr>
<td>
<label for="HomeState">
Province</label><br />
<select class="cat_dropdown" id="HomeState" name="HomeState">
<option value=" " selected="true">-- Please select --</option>
<option value="Eastern Cape">Eastern Cape</option>
<option value="Free State">Free State</option>
<option value="Gauteng">Gauteng</o ption>
<option value="KwaZulu-Natal">KwaZ ulu-Natal< /option>
<option value="Limpopo">Limpopo</o ption>
<option value="Mpumalanga">Mpumala nga</optio n>
<option value="Namibia">Namibia</o ption>
<option value="Northern Cape">Northern Cape</option>
<option value="North West">North West</option>
<option value="Western Cape">Western Cape</option>
</select><span class="req">•</span>
</td>
<td>
<label for="HomeZip">
Postcode</label><br />
<input type="text" name="HomeZip" maxlength="255" id="HomeZip" class="cat_textbox" /><span
class="req">•</span>
</td>
</tr>
<tr>
<td class="tail">
<label for="CellPhone">
Cell Phone Number</label><br />
<input type="text" name="CellPhone" maxlength="255" id="CellPhone" class="cat_textbox" /><span
class="req">•</span>
</td>
<td class="tail">
<label for="WorkPhone">
Work Phone Number</label><br />
<input type="text" name="WorkPhone" maxlength="255" id="WorkPhone" class="cat_textbox" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="CAT_Custom_67043" value="Yes" id="CAT_Custom_67043_0" />
<label>
Do you accept the <a href="/terms" target="_blank">Terms and Conditions</a>?</label>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Submit" id="catwebformbutton" class="cat_button" />
</td>
</tr>
</tbody>
</table>
<script type="text/javascript" src="/CatalystScripts/Vali dationFunc tions.js"> </script>
<script type="text/javascript">
//<![CDATA[
var submitcount32339 = 0;
function checkWholeForm32339(theFor m) {
var why = "";
if (theForm.FirstName) why += isEmpty(theForm.FirstName. value, "First Name");
if (theForm.LastName) why += isEmpty(theForm.LastName.v alue, "Last Name");
if (theForm.EmailAddress) why += checkEmail(theForm.EmailAd dress.valu e);
if (theForm.Username) why += isEmpty(theForm.Username.v alue, "Username");
if (theForm.Password && theForm.PasswordConfirm) {
why += isEmpty(theForm.Password.v alue, "Password"); why += isEmpty(theForm.PasswordCo nfirm.valu e, "Confirm Password");
if (theForm.Password.value != theForm.PasswordConfirm.va lue) why += appendBreak("- Password and its confirmation do not match.");
if (theForm.Password.value.le ngth < 6) why += appendBreak("- Password must be 6 characters or longer.");
}
if (theForm.HomeAddress) why += isEmpty(theForm.HomeAddres s.value, "Home Address");
if (theForm.HomeCity) why += isEmpty(theForm.HomeCity.v alue, "Home City");
if (theForm.HomeState) why += isEmpty(theForm.HomeState. value, "Home Province");
if (theForm.HomeZip) why += isEmpty(theForm.HomeZip.va lue, "Home Postcode");
if (theForm.CellPhone) why += isEmpty(theForm.CellPhone. value, "Cell Phone Number");
if (theForm.CAT_Custom_67043) why += checkSelected(theForm.CAT_ Custom_670 43, "Terms and Conditions");
if (why != "") {
alert(why);
return false;
}
if (submitcount32339 == 0) {
submitcount32339++; theForm.submit();
return false;
} else {
alert("Form submission is in progress.");
return false;
}
}
//]]>
</script>
</form>
<form enctype="multipart/form-da
onsubmit="return checkWholeForm32339(this)"
<table cellspacing="0" cellpadding="2" border="0" class="webform">
<tbody>
<tr>
<td>
<label for="Title">
Title</label><br />
<select name="Title" id="Title" class="cat_dropdown_smalle
<option value=" " selected="true">-- Please select --</option>
<option value="183558">DR</option>
<option value="183557">MISS</optio
<option value="183554">MR</option>
<option value="183555">MRS</option
<option value="183556">MS</option>
</select>
</td>
</tr>
<tr>
<td class="tail">
<label for="FirstName">
First Name</label><br />
<input type="text" name="FirstName" maxlength="255" id="FirstName" class="cat_textbox" /><span
class="req">•</span>
</td>
<td class="tail">
<label for="LastName">
Last Name</label><br />
<input type="text" name="LastName" maxlength="255" id="LastName" class="cat_textbox" /><span
class="req">•</span>
</td>
</tr>
<tr>
<td>
<label for="EmailAddress">
Email Address</label><br />
<input type="text" onchange="document.getElem
name="EmailAddress" maxlength="255" id="EmailAddress" class="cat_textbox" /><span
class="req">•</span>
</td>
</tr>
<tr class="hidden">
<td>
<label for="Username">
Username</label><br />
<input type="text" name="Username" maxlength="255" id="Username" class="cat_textbox" /><span
class="req">•</span>
</td>
</tr>
<tr>
<td class="tail">
<label for="Password">
Password</label><br />
<input type="password" name="Password" maxlength="255" id="Password" class="cat_textbox" /><span
class="req">•</span>
</td>
<td class="tail">
<label for="PasswordConfirm">
Confirm Password</label><br />
<input type="password" name="PasswordConfirm" maxlength="255" id="PasswordConfirm"
class="cat_textbox" /><span class="req">•</span>
</td>
</tr>
<tr>
<td>
<label for="HomeAddress">
Home Address</label><br />
<input type="text" name="HomeAddress" maxlength="500" id="HomeAddress" class="cat_textbox" /><span
class="req">•</span>
</td>
<td>
<label for="HomeCity">
City</label><br />
<input type="text" name="HomeCity" maxlength="255" id="HomeCity" class="cat_textbox" /><span
class="req">•</span>
</td>
</tr>
<tr>
<td>
<label for="HomeState">
Province</label><br />
<select class="cat_dropdown" id="HomeState" name="HomeState">
<option value=" " selected="true">-- Please select --</option>
<option value="Eastern Cape">Eastern Cape</option>
<option value="Free State">Free State</option>
<option value="Gauteng">Gauteng</o
<option value="KwaZulu-Natal">KwaZ
<option value="Limpopo">Limpopo</o
<option value="Mpumalanga">Mpumala
<option value="Namibia">Namibia</o
<option value="Northern Cape">Northern Cape</option>
<option value="North West">North West</option>
<option value="Western Cape">Western Cape</option>
</select><span class="req">•</span>
</td>
<td>
<label for="HomeZip">
Postcode</label><br />
<input type="text" name="HomeZip" maxlength="255" id="HomeZip" class="cat_textbox" /><span
class="req">•</span>
</td>
</tr>
<tr>
<td class="tail">
<label for="CellPhone">
Cell Phone Number</label><br />
<input type="text" name="CellPhone" maxlength="255" id="CellPhone" class="cat_textbox" /><span
class="req">•</span>
</td>
<td class="tail">
<label for="WorkPhone">
Work Phone Number</label><br />
<input type="text" name="WorkPhone" maxlength="255" id="WorkPhone" class="cat_textbox" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="CAT_Custom_67043" value="Yes" id="CAT_Custom_67043_0" />
<label>
Do you accept the <a href="/terms" target="_blank">Terms and Conditions</a>?</label>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Submit" id="catwebformbutton" class="cat_button" />
</td>
</tr>
</tbody>
</table>
<script type="text/javascript" src="/CatalystScripts/Vali
<script type="text/javascript">
//<![CDATA[
var submitcount32339 = 0;
function checkWholeForm32339(theFor
var why = "";
if (theForm.FirstName) why += isEmpty(theForm.FirstName.
if (theForm.LastName) why += isEmpty(theForm.LastName.v
if (theForm.EmailAddress) why += checkEmail(theForm.EmailAd
if (theForm.Username) why += isEmpty(theForm.Username.v
if (theForm.Password && theForm.PasswordConfirm) {
why += isEmpty(theForm.Password.v
if (theForm.Password.value != theForm.PasswordConfirm.va
if (theForm.Password.value.le
}
if (theForm.HomeAddress) why += isEmpty(theForm.HomeAddres
if (theForm.HomeCity) why += isEmpty(theForm.HomeCity.v
if (theForm.HomeState) why += isEmpty(theForm.HomeState.
if (theForm.HomeZip) why += isEmpty(theForm.HomeZip.va
if (theForm.CellPhone) why += isEmpty(theForm.CellPhone.
if (theForm.CAT_Custom_67043)
if (why != "") {
alert(why);
return false;
}
if (submitcount32339 == 0) {
submitcount32339++; theForm.submit();
return false;
} else {
alert("Form submission is in progress.");
return false;
}
}
//]]>
</script>
</form>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.