| | |
HELP! With Small Java Code....
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2005
Posts: 20
Reputation:
Solved Threads: 0
Hi All -
Can you please look at this code for me?
I need to be able to have this script LOAD A URL when the checkbox is checked and the SUBMIT is pressed....
Thanks so much!!!
[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 terms to submit form")
return false
}
}
}
</head>
<body>
<form name="agreeform" onSubmit="return defaultagree(this)">
Here is form or text<br>
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"><b>I agree to the above terms</b><br>
<input type="Submit" value="Submit!" disabled>
</form>
<script>
//change two names below to your form's names
document.forms.agreeform.agreecheck.checked=false
</script>
</body> [/html]
Can you please look at this code for me?
I need to be able to have this script LOAD A URL when the checkbox is checked and the SUBMIT is pressed....
Thanks so much!!!
[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 terms to submit form")
return false
}
}
}
</head>
<body>
<form name="agreeform" onSubmit="return defaultagree(this)">
Here is form or text<br>
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"><b>I agree to the above terms</b><br>
<input type="Submit" value="Submit!" disabled>
</form>
<script>
//change two names below to your form's names
document.forms.agreeform.agreecheck.checked=false
</script>
</body> [/html]
Last edited by tgreer; Sep 12th, 2006 at 12:45 pm. Reason: Fixed code tags.
Hi there,
Check this code
Rahul
Http://www.katarey.com
Check this code
HTML and CSS Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <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 terms to submit form") return false } } } function goToURL() { var i, args=goToURL.arguments; document.returnValue = false; for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'"); } //--> </script> </head> <body> <form method="get" name="agreeform" onsubmit="goToURL('parent','URL');return document.returnValue" > Here is form or text<br> <input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"> <b>I agree to the above terms</b><br> <input type="Submit" value="Submit!" disabled onClick="return defaultagree(this)"> </form> <script> //change two names below to your form's names document.forms.agreeform.agreecheck.checked=false </script> </body> </html>
Rahul
Http://www.katarey.com
•
•
Join Date: May 2005
Posts: 20
Reputation:
Solved Threads: 0
•
•
•
•
Hi there,
Check this code
HTML and CSS Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <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 terms to submit form") return false } } } function goToURL() { var i, args=goToURL.arguments; document.returnValue = false; for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'"); } //--> </script> </head> <body> <form method="get" name="agreeform" onsubmit="goToURL('parent','URL');return document.returnValue" > Here is form or text<br> <input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"> <b>I agree to the above terms</b><br> <input type="Submit" value="Submit!" disabled onClick="return defaultagree(this)"> </form> <script> //change two names below to your form's names document.forms.agreeform.agreecheck.checked=false </script> </body> </html>
Rahul
Http://www.katarey.com
•
•
•
•
THANK YOU! For that.... Where can I place the URL address that I want it to goto after Submit though? That is, if I dont wnt it to be parent or current page.....
well you just need to put the URL and target window here
<form method="get" name="agreeform" onsubmit="goToURL('parent','URL');return document.returnValue" >
Here is form or text<br>
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)">
<b>I agree to the above terms</b><br>
<input type="Submit" value="Submit!" disabled onClick="return defaultagree(this)">
</form>Best Regards,
Rahul
http://www.katarey.com
Last edited by katarey; Oct 25th, 2006 at 10:39 am.
![]() |
Similar Threads
- download jar files using java code (Java)
- I want to know about the java code. Help please!!!! (Java)
- Move out java code from jsp (Java)
- Help with Java code (Java)
- Can N E 1 Help!!!! -- Need sample Java code (Java)
- java code newbie (Java)
Other Threads in the HTML and CSS Forum
- Previous Thread: HTML-CSS trouble
- Next Thread: Link html in a folder???
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization perl pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7 xml xsl





