Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Elements not found in Firefox, works well with IE

    Hi,


    I have here a piece of my code. This code is supposed to change a password. It works well with IE but just can't find the elements in Firefox. I have already tried using getElementById() but having same results. Does anyone know of any workaround? Thanks.


    Regards,
    Andrew


    <html lang="en">
    <head>
    <title>change password</title>

    <script language="JavaScript">
    <!--


    var messageIndex = 0;
    var errorMessage = '';
    var messagesArray = new Array();

    function showMessages() {

    if (messageIndex > 0) {
    for (j = 0; j < messageIndex; j++) {
    errorMessage += messagesArray[j] + '\n';
    }
    alert(errorMessage);
    return false;
    }
    }


    -->
    </script>

    <script language="JavaScript">
    <!--

    var bStay=false;
    var aHelp;
    var aFields;
    var iWidth;
    var sWidth;
    var sOption;
    var sHtml;
    var i,iX,iY,iClX,iClY;
    var JQPrompt="";
    var inputType;
    var fieldName;
    var inputType1;
    var fieldName1;
    var strAction;
    var status="";

    function processData()
    {
    var i;
    idHelp.style.visibility='hidden';

    _changePassword();
    }

    function JQPopOut()
    {
    if (!bStay) idHelp.style.visibility="hidden";
    }
    document.write('<span style="visibility:hidden;" id="idHelp"> </span>');


    function JQPopUpPrompt()
    {
    var param;

    var counter;
    var value1;
    var value2;

    sHtml=
    '<table cellpadding="0" cellspacing="0" align="center">' +
    '<tr><td>'+
    '<form name="frmJQ" id="idJQ">';

    sHtml+=
    '<tr><td>new password</font></td><td><input type="password" name="newPassword" size="20" class="textbox" value=""></td></tr>' +
    '<tr><td>confirm password</font></td><td><input type="password" name="conPassword" size="20" class="textbox" value=""></td></tr>';

    sHtml+=
    '<tr align="center"><td colspan="6"><table cellspacing="2" align="center"><tr align="center"><td><button name="cmdOK" class="buttonPopup" onClick="JQPrompt=document.forms.frmJQ; processData(); return false;">Ok</button></td>' +
    '<td><button name="cmdCancel" class="buttonPopup" onClick="idHelp.style.visibility=\'hidden\'; bStay=false;">Cancel</button>' +
    '</td></tr></table></td></tr></form></tr></table>';
    idHelp.innerHTML=sHtml;

    iClX=330;
    iClY=150;
    iX = document.body.clientWidth - iClX;
    iY = document.body.clientHeight - iClY;
    if ( iX < idHelp.offsetWidth)
    idHelp.style.left = document.body.scrollLeft + iClX - idHelp.offsetWidth;
    else
    idHelp.style.left = document.body.scrollLeft + iClX;

    if (iY < idHelp.offsetHeight)
    idHelp.style.top = document.body.scrollTop + iClY - idHelp.offsetHeight;
    else
    idHelp.style.top = document.body.scrollTop + iClY;
    idHelp.style.visibility="visible";
    idHelp.style.position="absolute";

    }
    //-->
    </script>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--SCRIPT language="JavaScript" src="../includes/pos.js"></SCRIPT-->
    <script type="text/javascript" language="javascript1.3"><!--
    page = 'subscriberDetails.html';
    //-->
    </script>
    <SCRIPT language="JavaScript" type="text/JavaScript">
    <!-- BEGIN
    function addGroup(group)
    {
    document.getElementById("groups").innerHTML += "<input name=\"groups\" type=\"hidden\" value=\""+group+"\">";
    }
    function addType(type)
    {
    document.getElementById("groups").innerHTML += "<input name=\"types\" type=\"hidden\" value=\""+type+"\">";
    }
    function changePassword()
    {
    JQPopUpPrompt();
    }
    function _changePassword()
    {
    var msg;
    var userId;

    for (i=0; i<JQPrompt.length; i++)
    {
    if (JQPrompt[i].name == "newPassword")
    {
    document.subscriberDetailsForm.newPassword.value=JQPrompt[i].value;
    }
    else if (JQPrompt[i].name == "conPassword")
    {
    document.subscriberDetailsForm.conPassword.value=JQPrompt[i].value;
    }
    }
    msg="";
    if (document.subscriberDetailsForm.newPassword.value == "" || document.subscriberDetailsForm.newPassword.value == null)
    {
    msg = "New Password is required.";
    }
    else if (document.subscriberDetailsForm.conPassword.value == "" || document.subscriberDetailsForm.conPassword.value == null)
    {
    msg = "Confirm Password is required.";
    }
    else if (document.subscriberDetailsForm.newPassword.value != document.subscriberDetailsForm.conPassword.value)
    {
    msg="Password Mismatch. Please try again.";
    }
    else if (document.subscriberDetailsForm.newPassword.value.length < 6 || document.subscriberDetailsForm.conPassword.value.length < 6)
    {
    msg="Password cannot be less than 6 characters.";
    }
    else if (document.subscriberDetailsForm.newPassword.value.length > 18 || document.subscriberDetailsForm.conPassword.value.length > 18)
    {
    msg="Password cannot be more than 18 characters.";
    }

    if (msg != "")
    {
    alert(msg);
    }
    else
    {
    document.subscriberDetailsForm.msisdn.value=document.subscriberDetailsForm.msisdn.value;
    document.subscriberDetailsForm.userId.value=document.subscriberDetailsForm.userId.value;
    document.subscriberDetailsForm.newPassword.value=document.subscriberDetailsForm.newPassword.value;
    document.subscriberDetailsForm.action.value = "changepassword";
    document.subscriberDetailsForm.submit();
    }
    }
    // End -->
    </SCRIPT>
    <script type="text/javascript" language="javascript">
    <!--
    //-->
    </script>
    </head>
    <body onload="showMessages();">
    <form name="subscriberDetailsForm" method="post" action="/simplicate2.1/subscriberDetails.do">

    <input type="hidden" name="action" value="details"></input>
    <input type="hidden" name="conPassword"/>
    <input type="hidden" name="newPassword"/>


    <table border="0" cellspacing="0" cellpadding="0" width="100%">
    <tr>
    <td>
    <input type="button" name="btnSubmit" value="Change Password" onclick="javascript:changePassword();" class="button"/>
    </td>

    </tr>
    </table>


    </form>
    </body>

    </html>

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just FYI, IE gives me an error if I try to change the password. It says

    document.subscriberDetailsForm.msisdn

    is not an object.

    But I must admit your code is a bit confusing to me. For example, is this supposed to do anything?

    Code:
    document.subscriberDetailsForm.msisdn.value=document.subscriberDetailsForm.msisdn.value;
    document.subscriberDetailsForm.userId.value=document.subscriberDetailsForm.userId.value;
    document.subscriberDetailsForm.newPassword.value=document.subscriberDetailsForm.newPassword.value;
    I'll look for a bit more to see if I see something.

    david_kw

  • #3
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok I made 2 changes and I don't know if it works but it doesn't give errors anymore.

    The first was to comment the 3 lines of code out that I mentioned in my previous post. This fixed the fact that msisdn isn't in the form and unless I'm missing something those lines didn't seem to do anything anyway.

    The second was to change your dynamic html to

    Code:
    sHtml=
    '<form name="frmJQ" id="idJQ">'+
    '<table cellpadding="0" cellspacing="0" align="center">' +
    '<tr><td>';
    
    sHtml+=
    '<tr><td>new password</font></td><td><input type="password" name="newPassword" size="20" class="textbox" value=""></td></tr>' +
    '<tr><td>confirm password</font></td><td><input type="password" name="conPassword" size="20" class="textbox" value=""></td></tr>';
    
    sHtml+=
    '<tr align="center"><td colspan="6"><table cellspacing="2" align="center"><tr align="center"><td><button name="cmdOK" class="buttonPopup" onClick="JQPrompt=document.forms.frmJQ; processData(); return false;">Ok</button></td>' +
    '<td><button name="cmdCancel" class="buttonPopup" onClick="idHelp.style.visibility=\'hidden\'; bStay=false;">Cancel</button>' +
    '</td></tr></table></td></tr></tr></table></form>';
    idHelp.innerHTML=sHtml;
    The only change I made (on purpose) was to move the <form> tag outside the outer <table> instead of in it. I think what you were seeing in FF was caused by this. It appears that FF was upset that you didn't close the <form> tag within the <td> so decided to throw it's own </form> tag in. That left all the inputs outside the form element so unaddressable. That is why it kept giving the error.

    Hopefully that helps.

    david_kw

  • #4
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,


    Wow, it works well now. Thanks so much. It was really a big help for me. Thanks again.



    Regards,
    Andrew


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •