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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    [resolved] javascript - onEditFieldFocus change button texts

    I have this javascript on top of my HTML codes, that enables the "Free Trial" button if the Checkbox=On.
    but since I am not a programmer, I need a good mind to help me edit this


    What I need is to Edit this so that,
    If focus on Voucher Code field and have at least 6 bytes entered, and also the CheckBox=ON, I want the "Trial" button to change to "Confirm".


    <script language="Javascript" type="text/javascript">
    function enable(){
    if (document.agreement_form.agreed.checked==''){
    document.agreement_form.submit_button.disabled=true
    }else{
    document.agreement_form.submit_button.disabled=false
    }
    }
    </script>

    <div style="float:right;width:200px;margin-left:15px;padding-left:15px;margin-top:15px;border-left:2px dotted #99CC00">

    <span style="font-weight:bold;font-family:Tahoma;font-size:10pt;">Voucher Code:</span><br/>

    <form style="font-family:Tahoma;font-size:8pt;" method="GET" action="$authaction" name="agreement_form">
    <input name="tok" value="$tok" type="hidden"/>
    <input name="redir" value="$redir" type="hidden"/>
    <input size="12" name="voucher" type="password"/>&nbsp;
    <button type="SUBMIT" disabled="disabled" name="submit_button"><strong>&nbsp; Free Trial&nbsp; </strong></button>

    <p>
    </p>
    <input name="agreed" onchange="enable()" type="checkbox"/> Signed & agreed to all terms and conditions.
    </form>
    Last edited by jthunder; 01-07-2012 at 08:01 PM. Reason: [SOLVED]

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,774
    Thanks
    55
    Thanked 518 Times in 515 Posts
    like this you mean?

    Code:
    <html>
    <head>
    </head>
    <body>
    <script type="text/javascript">
    function enable(){
    if (document.agreement_form.agreed.checked==true){
    document.agreement_form.submit_button.disabled=false;
    if (document.agreement_form.voucher.value.length>5){
    document.agreement_form.submit_button.value="confirm";
    }
    }else{
    document.agreement_form.submit_button.disabled=true;
    }
    }
    </script>
    
    <div style="float:right;width:200px;margin-left:15px;padding-left:15px;margin-top:15px;border-left:2px dotted #99CC00">
    
    <span style="font-weight:bold;font-family:Tahoma;font-size:10pt;">Voucher Code:</span><br/>
    
    <form style="font-family:Tahoma;font-size:8pt;" method="GET" action="$authaction" name="agreement_form">
    <input name="tok" value="$tok" type="hidden"/>
    <input name="redir" value="$redir" type="hidden"/>
    <input size="12" name="voucher" onkeyup="enable()" type="password"/>&nbsp;<br>
    <input type="submit" disabled="true" name="submit_button" value="Free Trial"/>
    
    <p>
    </p>
    <input name="agreed" onclick="enable()" type="checkbox"/> Signed & agreed to all terms and conditions.
    </form> 
    </body>
    </html>

  • #3
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    This will also run the check when the checkbox is toggled:
    Code:
    <html>
    <head>
    </head>
    <title>TEST</title>
    <body>
    
    <div style="float:right;width:200px;margin-left:15px;padding-left:15px;margin-top:15px;border-left:2px dotted #99CC00">
    
    <span style="font-weight:bold;font-family:Tahoma;font-size:10pt;">Voucher Code:</span><br/>
    
    <form style="font-family:Tahoma;font-size:8pt;" method="GET" action="$authaction" name="agreement_form">
    <input name="tok" value="$tok" type="hidden"/>
    <input name="redir" value="$redir" type="hidden"/>
    <input size="12" name="voucher" id = "voucher" type="password"/><br>
    <button type="SUBMIT" disabled="xdisabled" name="submit_button"><strong>&nbsp; Free Trial&nbsp; </strong></button>
    <p>
    <input name="agreed" onclick="enable(this, submit_button)" type="checkbox"/> Signed & agreed to all terms and conditions.
    </form> 
    </div>
    
    <script type="text/javascript">
    
    function enable( box, btn )
    {
      btn.disabled = !box.checked;
      
      fCheck.call( box.form.voucher );
    }
    
    document.getElementById( "voucher" ).onkeyup = fCheck
    
    function fCheck()
    {
     var s1 = "<strong>&nbsp; Free Trial&nbsp; </strong>",  
         s2 = "<strong>&nbsp; Confirm&nbsp; </strong>" ;
        
     this.form.submit_button.innerHTML = ( this.value.length >= 6 && this.form.agreed.checked ? s2 : s1 );  
    }
    
    </script>
    </body>
    </html>

  • Users who have thanked Logic Ali for this post:

    jthunder (01-08-2012)

  • #4
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hey Xelowho and Logic Ali. Thanks to both of you. I tried them both and they are great. Have a great day and hopefully will head this place again. Thanks again.

    I have posted another help about PHP IP tracking behind the proxy. Maybe you can give it shot? Thanks again guys.
    http://www.codingforums.com/showthre...53#post1178353
    Last edited by jthunder; 01-07-2012 at 09:34 PM. Reason: added help requests

  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    javascript - onEditFieldFocus change button texts

    I missed this one on this thread,

    I need to add to the javacscript to hide the codes. Is there a way to turn off the "View Code" on the user browser so no one can see the source behind. Is there away to do this. Thanks again,'
    Last edited by jthunder; 01-08-2012 at 03:34 AM. Reason: missed one questions

  • #6
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,774
    Thanks
    55
    Thanked 518 Times in 515 Posts
    No. Passwords and other sensitive information should be stored on the server. Treat anything you do in javascript as visible to everybody.

  • Users who have thanked xelawho for this post:

    jthunder (01-08-2012)

  • #7
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks for the info. Have a nice evening.

  • #8
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    PHP and remote IP proxy

    HI Do you think you can help me with this?
    PHP - server behind proxy, IP tracking

    Thanks in advance.


  •  

    Posting Permissions

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