check box enable button

Reply

Join Date: Mar 2008
Posts: 4
Reputation: austin-khoi is an unknown quantity at this point 
Solved Threads: 0
austin-khoi austin-khoi is offline Offline
Newbie Poster

check box enable button

 
0
  #1
Mar 31st, 2008
i can't do this form, the button will be disabled when page load and only be enabled when one tick in the checkbox ( if the checkbox is unticked , the button will be disabled again). anyone help me ? thanks
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: check box enable button

 
0
  #2
Mar 31st, 2008
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function enableButton() {
  5. if(document.getElementById('option').checked){
  6. document.getElementById('edit').disabled='';
  7. } else {
  8. document.getElementById('edit').disabled='true';
  9. }
  10. }
  11. </script>
  12. </head>
  13. <body onload="enableButton();">
  14. <form method="post" action="test5.php">
  15. <input type="checkbox" name="option" id="option" onclick="javascript:enableButton();">Enable<br>
  16. <input type="button" name="button" value="Edit" id="edit">
  17. </form>
  18. </body>
  19. </html>

Cheers,
Naveen
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 3
Reputation: Mahesh_J is an unknown quantity at this point 
Solved Threads: 0
Mahesh_J Mahesh_J is offline Offline
Newbie Poster

Re: check box enable button

 
0
  #3
Jun 22nd, 2009
ok, its good
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 6
Reputation: Dasjetta is an unknown quantity at this point 
Solved Threads: 0
Dasjetta Dasjetta is offline Offline
Newbie Poster

Re: check box enable button

 
0
  #4
Sep 13th, 2009
Originally Posted by nav33n View Post
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function enableButton() {
  5. if(document.getElementById('option').checked){
  6. document.getElementById('edit').disabled='';
  7. } else {
  8. document.getElementById('edit').disabled='true';
  9. }
  10. }
  11. </script>
  12. </head>
  13. <body onload="enableButton();">
  14. <form method="post" action="test5.php">
  15. <input type="checkbox" name="option" id="option" onclick="javascript:enableButton();">Enable<br>
  16. <input type="button" name="button" value="Edit" id="edit">
  17. </form>
  18. </body>
  19. </html>

Cheers,
Naveen
Hi,

I'm new to this site and I know absolutely nothing about writing script of any kind. I am building a website using iWeb and I need to to be able to create a button on my webpage exactly like the one above. How do I make the button click go to a URL? For example I want this button to activate when the check mark is added and then when the actual button is clicked I want it to take my visitor to a link of my choice.

Thank you....

Jay
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: check box enable button

 
1
  #5
Sep 14th, 2009
Hi! Welcome to Daniweb.. Is this what you want ?
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function enableButton() {
  5. if(document.getElementById('option').checked){
  6. document.getElementById('b1').disabled='';
  7. } else {
  8. document.getElementById('b1').disabled='true';
  9. }
  10. }
  11. </script>
  12. </head>
  13. <body onload="enableButton();">
  14. <form method="post">
  15. <input type="checkbox" name="option" id="option" onclick="javascript:enableButton();">Enable<br>
  16. <input type="button" name="b1" value="Click" id="b1" onclick=location.replace('http://www.google.com') />
  17. </form>
  18. </body>
  19. </html>
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 6
Reputation: Dasjetta is an unknown quantity at this point 
Solved Threads: 0
Dasjetta Dasjetta is offline Offline
Newbie Poster

Re: check box enable button

 
0
  #6
Sep 14th, 2009
Originally Posted by nav33n View Post
Hi! Welcome to Daniweb.. Is this what you want ?
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function enableButton() {
  5. if(document.getElementById('option').checked){
  6. document.getElementById('b1').disabled='';
  7. } else {
  8. document.getElementById('b1').disabled='true';
  9. }
  10. }
  11. </script>
  12. </head>
  13. <body onload="enableButton();">
  14. <form method="post">
  15. <input type="checkbox" name="option" id="option" onclick="javascript:enableButton();">Enable<br>
  16. <input type="button" name="b1" value="Click" id="b1" onclick=location.replace('http://www.google.com') />
  17. </form>
  18. </body>
  19. </html>
We are getting close. When I put this code in my site and run it from the webpage it doesn't work properly. What happens is it opens google.com in a very tiny window where the "Click" button was. I don't want a pop up window but rather have it load google.com full size in the current window.

I would also like to be able to format it a little. I want to be able to place the check box on the right and be able to either center the "Click" button or position it on the left.

Thank you so much for the help....

Jay
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 6
Reputation: Dasjetta is an unknown quantity at this point 
Solved Threads: 0
Dasjetta Dasjetta is offline Offline
Newbie Poster

Re: check box enable button

 
0
  #7
Sep 15th, 2009
I don't know if this makes a difference but I'm inserting the code as a Widget in iWeb 09. I think it sees the automatically generated frame of the Widget as the boundary when opening up the URL upon the button click. Can we work around this?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: check box enable button

 
-1
  #8
Sep 16th, 2009
We are getting close. When I put this code in my site and run it from the webpage it doesn't work properly. What happens is it opens google.com in a very tiny window where the "Click" button was. I don't want a pop up window but rather have it load google.com full size in the current window.
I don't know if this makes a difference but I'm inserting the code as a Widget in iWeb 09.
It works as it is. I haven't used iweb09, so I don't have the slightest clue
If you post your relevant code, maybe someone who has experience on iweb 09 can help you out!
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,380
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 167
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: check box enable button

 
0
  #9
Sep 16th, 2009
  1. <input type="button" name="b1" value="Click" id="b1" onclick="top.location.replace('http://www.google.com');" />
Last edited by almostbob; Sep 16th, 2009 at 7:08 am.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 6
Reputation: Dasjetta is an unknown quantity at this point 
Solved Threads: 0
Dasjetta Dasjetta is offline Offline
Newbie Poster

Re: check box enable button

 
0
  #10
Sep 16th, 2009
Originally Posted by almostbob View Post
  1. <input type="button" name="b1" value="Click" id="b1" onclick="top.location.replace('http://www.google.com');" />
Thank you That did the trick. Is there any way to format this within the Widget window? For instance I want to be able to center the button and put the check box to the right side in the box.

Also, it is possible to make a description word such as ENABLE for the check box to be a hyper link?

My intent for this little gem is to use it as a way to verify that a customer has read and agrees to my legal terms and condition before being able to order the product. The hyperlink will take then to the terms and conditions page.

To see an example of this code in use see my page http://www.holiday-scooters.com/HSR/...hair_Info.html
Last edited by Dasjetta; Sep 16th, 2009 at 7:46 am.
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC