943,910 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 11520
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 31st, 2008
0

check box enable button

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
austin-khoi is offline Offline
4 posts
since Mar 2008
Mar 31st, 2008
0

Re: check box enable button

php Syntax (Toggle Plain Text)
  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
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Jun 22nd, 2009
0

Re: check box enable button

ok, its good
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Mahesh_J is offline Offline
3 posts
since Jun 2009
Sep 13th, 2009
0

Re: check box enable button

Click to Expand / Collapse  Quote originally posted by nav33n ...
php Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Dasjetta is offline Offline
6 posts
since Sep 2009
Sep 14th, 2009
1

Re: check box enable button

Hi! Welcome to Daniweb.. Is this what you want ?
php Syntax (Toggle Plain Text)
  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>
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Sep 14th, 2009
0

Re: check box enable button

Click to Expand / Collapse  Quote originally posted by nav33n ...
Hi! Welcome to Daniweb.. Is this what you want ?
php Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Dasjetta is offline Offline
6 posts
since Sep 2009
Sep 15th, 2009
0

Re: check box enable button

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Dasjetta is offline Offline
6 posts
since Sep 2009
Sep 16th, 2009
-1

Re: check box enable button

Quote ...
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.
Quote ...
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!
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Sep 16th, 2009
0

Re: check box enable button

html Syntax (Toggle Plain Text)
  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.
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Sep 16th, 2009
0

Re: check box enable button

Click to Expand / Collapse  Quote originally posted by almostbob ...
html Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Dasjetta is offline Offline
6 posts
since Sep 2009

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 PHP Forum Timeline: Need help
Next Thread in PHP Forum Timeline: Need Help in sending n receiving verification email





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


Follow us on Twitter


© 2011 DaniWeb® LLC