Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

HTML Tag Help

Options
  • 06-01-2005 11:15am
    #1
    Registered Users Posts: 155 ✭✭


    Hello Everyone,
    I need a little help regarding HTML. I am creating an introduction web-page with pilocies etc & what i want to do is, when a user reads these regulations he must accept them, eg. I Agree or I Disagree.
    So for instance there will be a radio button next to each option & then underneath it an Enter button.
    What I am trying to achieve is when then hit the agree option & click enter it will carry them directly to the web, on the other had
    when they have the I Disagree option checked and go for hittin the enter button it will carry them to a web page that will say access denied.....



    Can anyone be of any help please....??


Comments

  • Registered Users Posts: 7,276 ✭✭✭kenmc


    you could do it so that the "onclick" of the button calls a teenys javascript which just does a "Location" according to which button is pressed.
    Alternatively, if you're using some sort of php or asp or whatever to handle it all, you could detect which button was pressed when handling the form and go to the correct page.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    What you're looking for is generally known as javascript form validation, googling for that should turn up plenty, you could also google "free javascript" and most of the top sites should have something. There's one called "accept terms" here that seems pretty close to what you want.


  • Registered Users Posts: 515 ✭✭✭NeverSayDie


    On the client side, you can use JavaScript to achieve this effect. Just have a script called from the form's "OnSubmit" event - this code will get executed when the user submits the form. Then, have that code check which radio button was selected (by giving the radio buttons labels, and testing their properties). Depending on which one was selected, redirect the user to the appropriate page. Here's some resources on JavaScript:

    http://www.w3schools.com/js/default.asp
    http://www.pageresource.com/jscript/

    Google should be able to find you lots more info.

    Edit: yep, Steven got there first.


  • Registered Users Posts: 7,276 ✭✭✭kenmc


    the danger of leaving it to the client side though is that if someone has javascript disabled, you don't know whats gonna happen. hence you should probably try to do it server side if possible


  • Registered Users Posts: 6,508 ✭✭✭daymobrew


    What if JavaScript is turned off? I can turn it off in Firefox (Edit, Preferences, Web Features).
    An alternative could be to have the 'Agree' and 'Disagree' items be links to the appropriate pages. They could be images.
    To use actual buttons (submit buttons but with different text)I think you have to have a script at the backend.


  • Advertisement
  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Also, if you use ServerSide script, you can set a session variable when the user has accepted the terms & conditions. On the page that is linked to after accepting the T&Cs, you can check for that session variable - if the session variable does not exist, then the person bypassed the T&C accept page.


  • Registered Users Posts: 155 ✭✭tranceenigma


    HI Again everyone,
    You may remember yesterday, that I posted the below note, thank you for such a good response, I spent some time yesterday tryin to get something to work from your sources, could not really get anything major goin.
    I suppose all I really want is something as basic and as straight forward as possible, for instance, when the radio button for I disagree is checked it will carry them to a warning page which I have made, on the other hand if they agree to it, it will carry them directly to the internet??
    I have the radio buttons created etc, all i need to is find some way to seperate the two.
    Does anyone have ideas, or perhaps examples that might give me some idea, all suggestions are welcome.

    Cherrs lads......



    "Hello Everyone,
    I need a little help regarding HTML. I am creating an introduction web-page with pilocies etc & what i want to do is, when a user reads these regulations he must accept them, eg. I Agree or I Disagree.
    So for instance there will be a radio button next to each option & then underneath it an Enter button.
    What I am trying to achieve is when then hit the agree option & click enter it will carry them directly to the web, on the other had
    when they have the I Disagree option checked and go for hittin the enter button it will carry them to a web page that will say access denied.....



    Can anyone be of any help please....??"


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Hi,

    I think the code below is what you are looking for - it is not really the best way to do things, as you really need server side code / authentication to validate user access but it does pretty much what you asked for:

    Hope this helps,

    Eoin
    <html>
    	<head>
    		<title>test page</title>
    		<script type="text/JavaScript">
    			function checkForm()
    			{
    				 /*
    				 The rad_Action form field is an array because there
    				 are two radio buttons with the same name.
    
    				 The first radio button in the array is the one
    				 that is checked if the person has accepted. If this is
    				 checked, then we can redirect to the success page.
    				*/
    				if (myFrm.rad_Accept[0].checked)
    				{
    					// user has accepted, redirect to success page
    					document.location.href="YourSuccessPage.html";
    				}
    				else if (myFrm.rad_Accept[1].checked)
    				{
    					// user has selected the "No" field
    					document.location.href="YourErrorPage.html";
    				}
    				else
    				{
    					// user has not accepted either option
    					alert("you have not selected an option");
    					return false;
    				}
    			}
    		</script>
    	</head>
    	<body>
    		<form name="myFrm" action="test.html" method="post">
    		<table>
    			<tr>
    				<th>Terms and Conditions:</th>
    			</tr>
    			<tr>
    				<td>
    					These are the terms and conditions here.
    					These are the terms and conditions here.
    					These are the terms and conditions here.
    					These are the terms and conditions here.
    					These are the terms and conditions here.
    					These are the terms and conditions here.
    					These are the terms and conditions here.
    					These are the terms and conditions here.
    					These are the terms and conditions here.
    				</td>
    			</tr>
    			<tr>
    				<td>Do you accept these terms and conditions?</td>
    			</tr>
    			<tr>
    				<td>
    					Yes <input type="radio" value="yes" name="rad_Accept"> /
    					No <input type="radio" value="no" name="rad_Accept">
    				</td>
    			</tr>
    			<tr>
    				<td>
    					<input type="button" value="submit" onClick="return checkForm()">
    				</td>
    			</tr>
    		</table>
    		</form>
    	</body>
    </html>
    


  • Registered Users Posts: 155 ✭✭tranceenigma


    eoin s thats excellent, i was just looking at your code & trying it out, its a great start, im going to try and work around it.....

    cheers again


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    send me a PM or reply to the thread if you have any questions at all...

    Eoin


  • Advertisement
Advertisement