In article <195dfbe4.0309091924.400e2998@posting.google.com >,
flash12345flash@hotmail.com (Paul Oakfleet) wrote:[color=blue]
> ...
> 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.[/color]
[color=blue]
> Here's my entire page:
>
> <html>
> <head>
> <script>[/color]
Should be <script language="javascript"> or for modern browsers
<script type="text/javascript">
[color=blue]
>
> var checkobj[/color]
not needed
[color=blue]
>
> 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
> }
> }
> }[/color]
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;
}
[color=blue]
> 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
> }
> }
> }[/color]
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;
}[color=blue]
>
> </script>
> <SCRIPT LANGUAGE="JavaScript">[/color]
drop these two lines. Why close the script element
just to restart it?
[color=blue]
>
> 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>[/color]
there's no <p> for this </p>
[color=blue]
> <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>[/color]
add name="submitter" to this <input>
[color=blue]
> <script>
> document.forms.agreeform.agreecheck.checked=false
> </script>
> </body>
> </html>[/color]