944,049 Members | Top Members by Rank

Ad:
Sep 12th, 2006
0

HELP! With Small Java Code....

Expand Post »
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]
Last edited by tgreer; Sep 12th, 2006 at 12:45 pm. Reason: Fixed code tags.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jeepj27 is offline Offline
20 posts
since May 2005
Oct 24th, 2006
0

Re: HELP! With Small Java Code....

Hi there,

Check this code
HTML and CSS Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <script>
  5. <!--
  6. var checkobj
  7.  
  8. function agreesubmit(el){
  9. checkobj=el
  10. if (document.all||document.getElementById){
  11. for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
  12. var tempobj=checkobj.form.elements[i]
  13. if(tempobj.type.toLowerCase()=="submit")
  14. tempobj.disabled=!checkobj.checked
  15. }
  16. }
  17. }
  18.  
  19. function defaultagree(el){
  20. if (!document.all&&!document.getElementById){
  21. if (window.checkobj&&checkobj.checked)
  22. return true
  23. else{
  24. alert("Please read/accept terms to submit form")
  25. return false
  26. }
  27. }
  28. }
  29.  
  30. function goToURL() {
  31.   var i, args=goToURL.arguments; document.returnValue = false;
  32.   for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
  33. }
  34. //-->
  35. </script>
  36. </head>
  37. <body>
  38. <form method="get" name="agreeform" onsubmit="goToURL('parent','URL');return document.returnValue" >
  39. Here is form or text<br>
  40. <input name="agreecheck" type="checkbox" onClick="agreesubmit(this)">
  41. <b>I agree to the above terms</b><br>
  42. <input type="Submit" value="Submit!" disabled onClick="return defaultagree(this)">
  43. </form>
  44. <script>
  45. //change two names below to your form's names
  46. document.forms.agreeform.agreecheck.checked=false
  47. </script>
  48. </body>
  49. </html>

Rahul
Http://www.katarey.com
Reputation Points: 39
Solved Threads: 23
Junior Poster
katarey is offline Offline
167 posts
since Jul 2005
Oct 25th, 2006
0

Re: HELP! With Small Java Code....

Click to Expand / Collapse  Quote originally posted by katarey ...
Hi there,

Check this code
HTML and CSS Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <script>
  5. <!--
  6. var checkobj
  7.  
  8. function agreesubmit(el){
  9. checkobj=el
  10. if (document.all||document.getElementById){
  11. for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
  12. var tempobj=checkobj.form.elements[i]
  13. if(tempobj.type.toLowerCase()=="submit")
  14. tempobj.disabled=!checkobj.checked
  15. }
  16. }
  17. }
  18.  
  19. function defaultagree(el){
  20. if (!document.all&&!document.getElementById){
  21. if (window.checkobj&&checkobj.checked)
  22. return true
  23. else{
  24. alert("Please read/accept terms to submit form")
  25. return false
  26. }
  27. }
  28. }
  29.  
  30. function goToURL() {
  31.   var i, args=goToURL.arguments; document.returnValue = false;
  32.   for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
  33. }
  34. //-->
  35. </script>
  36. </head>
  37. <body>
  38. <form method="get" name="agreeform" onsubmit="goToURL('parent','URL');return document.returnValue" >
  39. Here is form or text<br>
  40. <input name="agreecheck" type="checkbox" onClick="agreesubmit(this)">
  41. <b>I agree to the above terms</b><br>
  42. <input type="Submit" value="Submit!" disabled onClick="return defaultagree(this)">
  43. </form>
  44. <script>
  45. //change two names below to your form's names
  46. document.forms.agreeform.agreecheck.checked=false
  47. </script>
  48. </body>
  49. </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.....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jeepj27 is offline Offline
20 posts
since May 2005
Oct 25th, 2006
0

Re: HELP! With Small Java Code....

Click to Expand / Collapse  Quote originally posted by jeepj27 ...
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.....
Hi there,

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.
Reputation Points: 39
Solved Threads: 23
Junior Poster
katarey is offline Offline
167 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: HTML-CSS trouble
Next Thread in HTML and CSS Forum Timeline: Link html in a folder???





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC