HELP! With Small Java Code....

Reply

Join Date: May 2005
Posts: 20
Reputation: jeepj27 is an unknown quantity at this point 
Solved Threads: 0
jeepj27 jeepj27 is offline Offline
Newbie Poster

HELP! With Small Java Code....

 
0
  #1
Sep 12th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 154
Reputation: katarey is an unknown quantity at this point 
Solved Threads: 20
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

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

 
0
  #2
Oct 24th, 2006
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
Freelance Web Designer & Developer
Http//www.Katarey.com
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 20
Reputation: jeepj27 is an unknown quantity at this point 
Solved Threads: 0
jeepj27 jeepj27 is offline Offline
Newbie Poster

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

 
0
  #3
Oct 25th, 2006
Originally Posted by katarey View Post
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.....
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 154
Reputation: katarey is an unknown quantity at this point 
Solved Threads: 20
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

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

 
0
  #4
Oct 25th, 2006
Originally Posted by jeepj27 View Post
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.
Freelance Web Designer & Developer
Http//www.Katarey.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC