Reply
funtion to hide submit button
Old 07-27-2006, 05:06 PM funtion to hide submit button
Novice Talker

Posts: 7
Name: Dan
I'm a javascripting noob and I need some help. I am trying to write a function that will make the user accept a terms of agreement. I have one radio button that says "accept" the other says "do not accept" I want to disable the submit button if the user chooses "do not accept", and the cancel button to redirect the page to the home page on click. If the user chooses "accpet" I want the submit button to enable, and on click action to take the user to the next page.

Does anyone know of a tutorial that could help me do this?

Thanks!
dan731028 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-27-2006, 06:56 PM Re: funtion to hide submit button
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Code:
document.your_form_name.your_submit_button.disabled = true;
document.your_form_name.your_cancel_button.disabled = false;
if (document.your_form_name.radio_button.options[0].selected) {
document.your_form_name.your_submit_button.disabled = false;
document.your_form_name.your_cancel_button.disabled = true;
}
Adjust accordingly.

As far as the redirection goes, you should use server side programming to take care of that. The exact code would depend on the language used.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 07-28-2006, 01:05 PM Re: funtion to hide submit button
Novice Talker

Posts: 7
Name: Dan
I don't know what I'm doing wrong here. Can anyone take a look at this code and tell me what's up? I'm not refering to the script right... ADAM thank's for the tip, but I'm a noob when it comes to this sort of stuff. I want to use php, but I'm no expert at that either.

here is my url:Untitled Document

see above for what I want to do.

Thanks for any help!!!

Last edited by dan731028 : 07-28-2006 at 01:11 PM.
dan731028 is offline
Reply With Quote
View Public Profile
 
Old 07-28-2006, 02:35 PM Re: funtion to hide submit button
funkdaddu's Avatar
Web Design Snob

Posts: 636
1) In general don't call your buttons by names that are used as methods or properties - like name, submit etc. submit is a function of a form so when you call document.formname.submit it thinks you're referencing the form's submit function and not an input.

2) your code needs to be called in a function from an onevent handler

HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Untitled Page</title>
		<script type="text/javascript"><!--
function setSubmit() {
	if (document.agreement.radiobutton1[0].checked) {
		document.agreement.submitbutton.disabled = false;
	} else {
		document.agreement.submitbutton.disabled = true;
	}
}

window.onload = function() {
		document.agreement.submitbutton.disabled = true;
}
//-->
</script>
	</head>

	<body bgcolor="#ffffff">
		<form action="requestform.html" method="post" name="agreement">
			<p><label><input type="radio" name="radiobutton1" value="submitbutton" onclick="setSubmit();">
        </label>
        I accept the terms and conditions<br>
				<label>        </label>
        <label><input type="radio" name="radiobutton1" value="canelbutton" checked onclick="setSubmit();">        
				I <strong>DO NOT</strong> </label>
				accept these terms and conditions<br>
				<label></label><br>
				<input type="submit" name="submitbutton" value="Submit">
          <input id="cancel" type="reset" name="cancel" value="Cancel" onclick="window.location='http://www.google.com/'"></p>
		</form>
	</body>

</html>
That should work.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 07-29-2006, 12:35 AM Re: funtion to hide submit button
Novice Talker

Posts: 7
Name: Dan
thanks for the help!
dan731028 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to funtion to hide submit button
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15379 seconds with 12 queries