accpept/decline chekboxes redirect.

Posted on 2006-05-11
Last Modified: 2012-08-13
I want to have 2 checkboxs where the user either accepts or declines the disclaimer. The checkboxed need to redirect automatically when they are clicked to the homepage if they decline and the main bit of the website if they decline.

Question by:roscoeh23
    LVL 6

    Accepted Solution

    you could just make 2 links if all you are doing is redirecting:

    <a href="homepage.htm">Accept</a>&nbsp;&nbsp;|&nbsp;&nbsp;
    <a href="mainbit.htm">Decline</a>

    With javascript:

    <script language="JavaScript"><!--
    function redirect(decision) {
      if (decision == "accept") {

    <form name="redirectForm">
    <input type="checkbox" onClick="redirect('accept');"> Accept&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="checkbox" onClick="redirect('decline');"> Decline&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    LVL 21

    Expert Comment

    by:Julian Matz
    Or you could use a server side language like PHP, that way you can be sure that no one accesses the page without having accepted the aggreement...

    The PHP page takes the form data and processes it:


    $accept = isset($_POST['accept']) ? $_POST['accept'] : '';

    if (empty($accept))  {
     header ('Location: aggreement.html');
    } elseif ($accept != 1) {
     header ('Location: rejected.html');

    .... You can now put your html here ... Only users who have accepted the agreement will be able to see this page ...

    Author Comment

    Nice Work!

    By the way the php version does not work as when you set the variable with

    $accept = isset($_POST['accept']) ? $_POST['accept'] : '';

    It is automatically set to empty and redirects to agreement.html

    LVL 21

    Expert Comment

    by:Julian Matz
    Yes, I know. That was the point. It will not be empty however if you post a variable called 'accept':

    <input type="radio" id="accept" name="accept" value="1" /> <label for="accept">I accept</label>

    It could also be that you have an older version of PHP, in which case you could use:

    $HTTP_POST_VARS instead of $_POST

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Create Mobile App Prototypes with Adobe XD

    This is a project-based course: we go through all the steps of creating a prototype from start to finish, using all the tools and features currently available in Adobe XD. You can complete the course in less than a day, plus all project files and fonts are included.

    Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now