473,513 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disable Submit Button until Accept Terms and Redirect Page on Submit

The script below will disable Submit button until user accept terms,
and will redirect user to another page after clicking on Submit
button.

The script seems to work fine on my PC (Windows XP, IE6), however I
don't know if it's written well. I would like the opinion of someone
who knows how to write these codes properly. Please let me know if
there're any logic errors.

PS: Please keep in mind that I didn't write this script, I found it
over the internet. Therefore do not make me responsible for (1)
copyright, (2) any damage this script may cause, (3) incompatibility,
(4) bugs this script may have.

Here's my entire page:

<html>
<head>
<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 Read/Accept our Terms of Service/Agreement to
continue.")
return false
}
}
}

</script>
<SCRIPT LANGUAGE="JavaScript">

var destination="redirectingpage.htm";

function redirect()
{
window.location = destination;
}

// End -->
</script>
</head>
<body>
<form method="post" name=agreeform onSubmit="return
defaultagree(this)" action="javascript:redirect()">
<iframe name="agreement" src="email/agreement.htm" border="0"
frameborder="0" marginwidth="3" marginheight="3" width="600"
height="110" style="border: 3px solid #294A63">
Your browser does not support inline frames or is currently configured
not to display inline frames.</iframe></p>
<input name="agreecheck" value="agree" type="checkbox"
onClick="agreesubmit(this)">I Agree to the above Terms of
Service/Agreement<br>
<input type="Submit" value="Continue" disabled></form>
<script>
document.forms.agreeform.agreecheck.checked=false
</script>
</body>
</html>
Jul 20 '05 #1
1 14124
In article <19**************************@posting.google.com >,
fl*************@hotmail.com (Paul Oakfleet) wrote:
...
The script seems to work fine on my PC (Windows XP, IE6), however I
don't know if it's written well. I would like the opinion of someone
who knows how to write these codes properly. Please let me know if
there're any logic errors.

PS: Please keep in mind that I didn't write this script, I found it
over the internet. Here's my entire page:

<html>
<head>
<script>
Should be <script language="javascript"> or for modern browsers
<script type="text/javascript">

var checkobj
not needed

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
}
}
}
No search needed. Just give the Submit button a
name, e.g., "submitter" (don't call it "submit"!).
Then you can write

function agreesubmit(checkobj) {
checkobj.form.submitter.disabled = !checkobj.checked;
}
function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please Read/Accept our Terms of Service/Agreement to
continue.")
return false
}
}
}
I don't know what that outer IF is for, and window.checkobj
looks bogus to me. Also el (for element?) is a poor name,
given it's really the form. Better code would be

function defaultagree(form) {
if (!form.agreecheck.checked) {
alert(Please Read/Accept our Terms of Service/Agreement to continue.");
}
return form.agreecheck.checked;
}
</script>
<SCRIPT LANGUAGE="JavaScript">
drop these two lines. Why close the script element
just to restart it?


var destination="redirectingpage.htm";

function redirect()
{
window.location = destination;
}

// End -->
</script>
</head>
<body>
<form method="post" name=agreeform onSubmit="return
defaultagree(this)" action="javascript:redirect()">
<iframe name="agreement" src="email/agreement.htm" border="0"
frameborder="0" marginwidth="3" marginheight="3" width="600"
height="110" style="border: 3px solid #294A63">
Your browser does not support inline frames or is currently configured
not to display inline frames.</iframe></p>
there's no <p> for this </p>
<input name="agreecheck" value="agree" type="checkbox"
onClick="agreesubmit(this)">I Agree to the above Terms of
Service/Agreement<br>
<input type="Submit" value="Continue" disabled></form>
add name="submitter" to this <input>
<script>
document.forms.agreeform.agreecheck.checked=false
</script>
</body>
</html>

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5884
by: Codeman II | last post by:
Hi there, I am building a form where the user must upload a picture and fill in his details. Now I have a problem as all of this is on the same form. How will I be able to have the Browse...
1
8453
by: Frawls | last post by:
Hi Can any one give me some help with this problem please? Here is the scenario: A user submits page 1 which is a web form. After the form has been submitted they are (redirected) onto...
2
3833
by: Frawls | last post by:
Hi Can any one give me some help with this problem please? Here is the scenario: A user submits page 1 which is a web form.
14
7162
by: Sinity | last post by:
Anyone knows the method/codes to disable the clicked button after first click by using .aspx-- to prevent people to click many time when waiting for the server response. I tried to do this by...
6
9058
by: Al Cohen | last post by:
I'm using a LinkButton to call some code, then do a redirect. The code does some queries, sends some emails, and takes a few moments before the redirect is performed. I'd like to disable my...
6
4029
by: GD | last post by:
Hi, I wonder how to disable the "submit" behavior of a button. What I want is to assign values to dynamically added user controls without page postback. Problem: dynamically created control can...
16
3407
by: Barry Gilmore | last post by:
Is there a way to disable a button after it is clicked? I am trying to avoid having someone click on it twice while they wait for it to process. Thank you!
2
2871
by: labmonkey111 | last post by:
I have a form that takes several seconds to run the javascript needed to prepare the form for PHP (selecting all items in a Select Multiple). Since it takes so long, I want to disable the Submit...
0
7175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7120
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5697
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4754
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1609
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
466
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.