Link to home
Start Free TrialLog in
Avatar of markerasmus
markerasmusFlag for United Kingdom of Great Britain and Northern Ireland

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.getElementById('Username').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?
Avatar of ajones2600fl
ajones2600fl

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?
Avatar of markerasmus

ASKER

The code is working fine for me in IE7 and Firefox. Only today someone let me know it wasn't working in IE6.  
I tested it in IE6, and it worked just fine.


screenshot.png
Mmm, interesting.  I have checked with the user and they confirm Javascritp is enabled. Here is the whole form:

<form enctype="multipart/form-data" method="post" action="/FormProcessv2.aspx?WebFormID=18180&amp;OID=1612829&amp;OTYPE=1&amp;EID=0&amp;CID=0&amp;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_smaller">
                    <option value=" " selected="true">-- Please select --</option>
                    <option value="183558">DR</option>
                    <option value="183557">MISS</option>
                    <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.getElementById('Username').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</option>
                    <option value="KwaZulu-Natal">KwaZulu-Natal</option>
                    <option value="Limpopo">Limpopo</option>
                    <option value="Mpumalanga">Mpumalanga</option>
                    <option value="Namibia">Namibia</option>
                    <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" />&nbsp;&nbsp;
                <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/ValidationFunctions.js"></script>

<script type="text/javascript">
    //<![CDATA[
    var submitcount32339 = 0;
    function checkWholeForm32339(theForm) {
        var why = "";
        if (theForm.FirstName) why += isEmpty(theForm.FirstName.value, "First Name");
        if (theForm.LastName) why += isEmpty(theForm.LastName.value, "Last Name");
        if (theForm.EmailAddress) why += checkEmail(theForm.EmailAddress.value);
        if (theForm.Username) why += isEmpty(theForm.Username.value, "Username");
        if (theForm.Password && theForm.PasswordConfirm) {
            why += isEmpty(theForm.Password.value, "Password"); why += isEmpty(theForm.PasswordConfirm.value, "Confirm Password");
            if (theForm.Password.value != theForm.PasswordConfirm.value) why += appendBreak("- Password and its confirmation do not match.");
            if (theForm.Password.value.length < 6) why += appendBreak("- Password must be 6 characters or longer.");
        }
        if (theForm.HomeAddress) why += isEmpty(theForm.HomeAddress.value, "Home Address");
        if (theForm.HomeCity) why += isEmpty(theForm.HomeCity.value, "Home City");
        if (theForm.HomeState) why += isEmpty(theForm.HomeState.value, "Home Province");
        if (theForm.HomeZip) why += isEmpty(theForm.HomeZip.value, "Home Postcode");        
        if (theForm.CellPhone) why += isEmpty(theForm.CellPhone.value, "Cell Phone Number");        
        if (theForm.CAT_Custom_67043) why += checkSelected(theForm.CAT_Custom_67043, "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>
ASKER CERTIFIED SOLUTION
Avatar of alien109
alien109
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial