Pop-up disclaimer

Discussion in 'JavaScript' started by daydream64, Jan 18, 2011.

  1. #1
    I have a window that pop-ups when the index page loads.
    In the pop-up is a disclaimer and when you click on the checkbox "I Agree" and submit it will bring you to our home web page. This works fine but I want another checkbox so that if someone "Disagrees" with the disclaimer they will be redirected to another web page.

    I can usually edit javascript on my own but this one stumped me. I will pay for help with this.

    Here is my code
    
    <script>
    var checkobj
    
    function agreesubmit(el){
    checkobj=el
    if (document.all||document.getElementById){
    for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
    var tempobj=checkobj.form.elements[i]
    if(tempobj.type.toLowerCase()=="submit")
    tempobj.disabled=!checkobj.checked
    }
    }
    }
    
    function defaultagree(el){
    if (!document.all&&!document.getElementById){
    if (window.checkobj&&checkobj.checked)
    return true
    else {alert('Please Accept our Disclaimer to continue')
    return false
    }
    }
    }
    // End -->
    </script>
    
    <SCRIPT LANGUAGE="JavaScript">
    
    var destination="";
    
    function redirect()
    {
    window.open ("/kmat/english/index.shtml");
    window.close()
    
    }
    // End -->
    </script>
    
    Code (markup):
    and table
    
    <form method="post" name="disclaimer" onSubmit="returndefaultagree(this)" action="javascript:redirect()">
    <iframe name="agreement" src="agreement.htm" border="0"
    frameborder="0" marginwidth="5" marginheight="5" width="600"
    height="250" style="border: 3px solid #294A63">
    <p>Your browser does not support inline frames or is currently configured not to display inline frames.</p>
    </iframe>
    <p><input name="agreecheck" value="agree" type="checkbox"
    onClick="agreesubmit(this)">I agree to the above Disclaimer</p>
    <input type="Submit" value="Continue" disabled></form>
    <script>
    document.forms.agreeform.agreecheck.checked=false
    </script>
    
    Code (markup):
     
    daydream64, Jan 18, 2011 IP
  2. daydream64

    daydream64 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Does anyone know what I can do??? I need some help here.
    I am not asking for someone to write the code for me...just tell me what I need to look at in order to get it to do what I want it to do. Thanks a bunch
     
    daydream64, Jan 19, 2011 IP
  3. dennisbrittv

    dennisbrittv Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Whats the url so i may see this in action?
     
    dennisbrittv, Jan 21, 2011 IP
  4. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is this where you got that code from?
    http://www.dynamicdrive.com/dynamicindex16/acceptterm.htm

    Looks way too complicated just for showing a button. This is what I came up with:
    
    <html>
    <head>
    <script type="text/javascript">
    function init() {
    	document.getElementById("agreeRadio").checked = false;
    	document.getElementById("disagreeRadio").checked = false;
    	document.getElementById("submitButton").disabled = true;
    }
    	
    function showSubmit() {
    	document.getElementById("submitButton").disabled = false;
    }
    
    function checkAgree() {
    	var agree = document.getElementById("agreeRadio").checked;
    	if (!agree) window.location = "disagree.html";
    	else window.location = "agree.html";
    }
    </script>
    </head>
    <body onload="init();">
    <form method="post" name="disclaimer" onSubmit="checkAgree();" action="javascript: return false;">
    <iframe name="agreement" src="agreement.html" border="0"
    frameborder="0" marginwidth="5" marginheight="5" width="600"
    height="250" style="border: 3px solid #294A63">
    <p>Your browser does not support inline frames or is currently configured not to display inline frames.</p>
    </iframe>
    <p><input id="agreeRadio" name="choice" value="agree" type="radio" onClick="showSubmit()">I agree to the above Disclaimer</p>
    <p><input id="disagreeRadio" name="choice" value="disagree" type="radio" onClick="showSubmit()">I disagree to the above Disclaimer</p>
    <input id="submitButton" type="Submit" value="Continue" disabled="disabled">
    </form>
    </body>
    </html>
    
    Code (markup):
    And these are the test files I used:
    
    agreement.html
    <html>
    <head></head>
    <body>
    Blah, blah, blah!
    </body>
    </html>
    
    agree.html
    <html>
    <head></head>
    <body>
    Yah! You agreed!
    </body>
    </html>
    
    disagree.html
    <html>
    <head></head>
    <body>
    Oh noes! You disagreed!
    </body>
    </html>
    
    Code (markup):
    Hope that works :D
     
    Last edited: Jan 22, 2011
    Cash Nebula, Jan 22, 2011 IP