To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Misc Help > ClientSide Technologies

ClientSide Technologies Discuss HTML/CSS/Javascript, and any other client-side technologies, here.

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-22-2006, 11:06 AM   #1
MMWizard
Junior Member
 
Join Date: May 2006
Posts: 4
[RESOLVED] conditional submit button???

Hello,

I'm creating a subscription form and i like to know how to create an interactive submit button.

What i want is a submit button which only can be used when they agree with the terms of conditions by checking a checkbox. Can u please tell me how i can do that???

Thanx in advance and greetz..

Gilbert
MMWizard is offline   Reply With Quote
Old 05-22-2006, 11:12 AM   #2
Houdini
Lost in Time (1970's)
 
Houdini's Avatar
 
Join Date: Jul 2004
Location: Nashville TN USA
Posts: 1,932
You would need to use JavaScript
Houdini is offline   Reply With Quote
Old 05-22-2006, 12:26 PM   #3
bogu
I code 4 beer ...
 
bogu's Avatar
 
Join Date: Nov 2002
Location: Romania
Posts: 1,743
This is the topic where u should post your question:
ClientSide Technologies
Discuss HTML/CSS/Javascript, and any other client-side technologies, here.

About the question:

There is disable <-- javascript event ...
__________________
/**
* The answer is so obvious, duh!
* It's like, whatever ...
*
* If your problem has been solved, PLEASE click the RESOLVED LINK under "Thread Tools"
*/
bogu is offline   Reply With Quote
Old 05-22-2006, 12:38 PM   #4
MMWizard
Junior Member
 
Join Date: May 2006
Posts: 4
Ohw, i'm sorry.
Im new(in coding PHP) and here at this forum and hoped there was something like this in php.
But i will look at the other topic to get some more result about the disable JAVASCRIPT EVENT. But thanx a lot for giving me some direction. I thought this would be the simplest part of my PHP form but never is ever like it seems...
MMWizard is offline   Reply With Quote
Old 05-22-2006, 04:10 PM   #5
bogu
I code 4 beer ...
 
bogu's Avatar
 
Join Date: Nov 2002
Location: Romania
Posts: 1,743
Look here I made u and example of what u need:

HTML Code:
<form>
	<input type="checkbox" name="chk" value="1" onclick="return _DoSomething(this);" />
	<input type="submit" name="btn" value="Bimbo :)" disabled />
</form>
<script>
	var _dd = document.forms[0];
	function _DoSomething(the_chk) {
		if (the_chk.checked) {
			_dd.btn.disabled = false;
		} else {
			_dd.btn.disabled = true;
		}
	}
</script>
Have fun coding.
__________________
/**
* The answer is so obvious, duh!
* It's like, whatever ...
*
* If your problem has been solved, PLEASE click the RESOLVED LINK under "Thread Tools"
*/
bogu is offline   Reply With Quote
Old 05-23-2006, 03:53 AM   #6
MMWizard
Junior Member
 
Join Date: May 2006
Posts: 4
hahaha... thank u very much. It works fine... Now i only have 2 figure out how it works so i can alter and use in other projects... Thank u

greetz Bimbo
MMWizard is offline   Reply With Quote
Old 05-23-2006, 04:01 AM   #7
bogu
I code 4 beer ...
 
bogu's Avatar
 
Join Date: Nov 2002
Location: Romania
Posts: 1,743
Quote:
Originally Posted by MMWizard
greetz Bimbo
__________________
/**
* The answer is so obvious, duh!
* It's like, whatever ...
*
* If your problem has been solved, PLEASE click the RESOLVED LINK under "Thread Tools"
*/
bogu is offline   Reply With Quote
Old 06-20-2007, 11:05 AM   #8
cretam
Senior Member
 
Join Date: Sep 2003
Location: Bordertown
Posts: 108
Been looking everywhere for help with this - thankyou

Quote:
Originally Posted by bogu
Look here I made u and example of what u need:

HTML Code:
<form>
	<input type="checkbox" name="chk" value="1" onclick="return _DoSomething(this);" />
	<input type="submit" name="btn" value="Bimbo :)" disabled />
</form>
<script>
	var _dd = document.forms[0];
	function _DoSomething(the_chk) {
		if (the_chk.checked) {
			_dd.btn.disabled = false;
		} else {
			_dd.btn.disabled = true;
		}
	}
</script>
Have fun coding.
I am so grateful you showed us an example - wasn't sure where to look. For some reason when I tick the box to accespt the terms my button doesn't display.
I have done the same as your example.
HTML Code:
<p><input type="checkbox" name="chk" value="1" onclick="return _DoSomething(this);" />Check to accept agreement. <a href="terms.php" target="_blank">View end user licence agreement</a></p>

     <p> <input type="submit" name="btn" value="Sign Up!" disabled /></p></form> 
I used the script in the header.

Any ideas why it's not working?
cretam is offline   Reply With Quote
Old 06-20-2007, 01:49 PM   #9
bradgrafelman
Pna lbh ernq guvf?
 
Join Date: Jul 2004
Location: 40.566N -89.731W, ~469ft above sea level
Posts: 11,488
I don't see any <form></form> tags in your HTML code example... for bogu's code to work properly, the checkbox and submit button must be placed inside a form (the first form on the page, in fact).

EDIT: Correction, I see an ending </form> tag, but no beginning <form> tag.
__________________
***If your problem has been solved, PLEASE click the RESOLVED LINK under "Thread Tools"***

"Well Bones, do the new medical facilities meet with your approval?" -- Kirk
"They do not. It's like working in a damn computer center" -- McCoy (Star Trek: TMP)

Useful links: Debugging 101 || NJOE || (Sig image) || Rolla Engineered Solutions, LLC
bradgrafelman is offline   Reply With Quote
Old 06-20-2007, 07:00 PM   #10
cretam
Senior Member
 
Join Date: Sep 2003
Location: Bordertown
Posts: 108
Form is included

I haven't included them because i didn't want to include the entire form but yes they are in form tags.
Here is the form:
PHP Code:
    <table border="0" cellspacing="0" cellpadding="0" width="450">
      <tr>
        <td class="pageName">Register as an Individual <p>&nbsp;</p></td>
      </tr>
      <tr><?php
    
include("Connections/conn.php");
    
  
$regions = @mysql_query('SELECT id, name FROM region ORDER BY name ASC');
  if (!
$regions) {
    exit(
'<p>Unable to obtain region list from the database.</p>');
  }

  
?>
        <td class="bodyText"><form action="login.php?do=new" method="post">              
   
    <?php
      
if (isset($message_new))                                  
           echo
"<tr><td colspan='2'><b>$message_new</b></td></tr>";
    
?>* Indicates required field.
     <fieldset>
    <legend>Personal Information</legend>
    <p>   <label for="newname">*Username</label>
     <input type="text" name="newname"
               value="<?php echo @$newname ?>"
               size="20" maxlength="20"></p>
  <p> <label for="newpass">*Password</label>
   <input type="password" name="newpass"
         value="<?php echo @$newpass ?>"
             size="10" maxlength="8"><br>Use only letters and numbers. Must be between 4 and 20 characters long.</p>
             <p> <label for="newpass1">*Confirm Password</label>
   <input type="password" name="newpass1"
         value="<?php echo @$newpass1 ?>"
             size="10" maxlength="8"></p>
  <p><label for="firstName">*First Name</label>
     <input type="text" name="firstName"
             value="<?php echo @$firstName ?>"
             size="40" maxlength="40"></p>
   <p><label for="lastName">*Last Name</label>
    <input type="text" name="lastName"
             value="<?php echo @$lastName ?>"
             size="40" maxlength="40"></p>
             <p><label for="dob">*Date of Birth</label>
    <input type="text" name="dob" id="demo1"
             value="<?php echo @$dob ?>"
             size="10" maxlength="10"> <a href="javascript:NewCal('demo1','ddmmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a></p>
             <p><label for="email">*Email Address</label>
     <input type="text" name="email" value="<?php echo @$email ?>"
             size="40" maxlength="40"></p>
              <p><label for="driverlicence">Drivers Licence</label>
     <input type="text" name="driverlicence" value="<?php echo @$driverlicence ?>"
             size="20" maxlength="20"></p>
             <p><label for="phone">*Phone</label>
     <input type="text" name="phone" value="<?php echo @$phone ?>"
             size="15" maxlength="20"></p>
       <p><label for="fax">Fax</label>
      <input type="text" name="fax" value="<?php echo @$fax ?>"
             size="15" maxsize="20"></p>
        <p><label for="mobile">Mobile</label>
     <input type="text" name="mobile" value="<?php echo @$mobile ?>"
             size="15" maxlength="15"></p>
   </fieldset>
  <fieldset><legend>Address Details</legend>
   <p><label for="street">*Street</label>
    <input type="text" name="street" value="<?php echo @$street ?>"
             size="40" maxlength="40"></p>
    <p><label for="city">*City</label>
     <input type="text" name="city" value="<?php echo @$city ?>"
             size="40" maxlength="40"></p>
   <p><label for="state">*State</label>
     <input type="text" name="state" value="<?php echo @$state ?>"
             size="4" maxlength="4"></p>
     <p><label for="postcode">*Postcode</label>
     <input type="text" name="zip" value="<?php echo @$zip ?>"
             size="4" maxsize="4"></p>
    
  
             <p><strong>*Select regions you are willing to work in:</strong></br></br><?php

  
while ($region = mysql_fetch_array($regions)) {

    
$rid = $region['id'];

    
$rname = htmlspecialchars($region['name']);

    echo
"<input type='checkbox' name='regions[]' value='$rid' />$rname </p>\n";
    }
    
    
    
?>


     </fieldset>
     <p><strong>To verify your registration please answer the following question:</strong>
    There are 3 colours on the aboriginal flag; black, yellow and ...?</br>(Type the other colour on the flag in the box below.) </p>
    <p><input type="text" name="logic" value="<?php echo @$logic ?>" /></p>
    <p><input type="checkbox" name="chk" value="1" onclick="return _DoSomething(this);" />Check to accept agreement. <a href="terms.php" target="_blank">View end user licence agreement</a></p>

     <p> <input type="submit" name="btn" value="Sign Up!" disabled /></p>
    
   </form></td>
      </tr>
    </table>
cretam is offline   Reply With Quote
Old 07-02-2007, 05:01 PM   #11
bradgrafelman
Pna lbh ernq guvf?
 
Join Date: Jul 2004
Location: 40.566N -89.731W, ~469ft above sea level
Posts: 11,488
Okay.. and where do you define the _DoSomething JS function in your code?
__________________
***If your problem has been solved, PLEASE click the RESOLVED LINK under "Thread Tools"***

"Well Bones, do the new medical facilities meet with your approval?" -- Kirk
"They do not. It's like working in a damn computer center" -- McCoy (Star Trek: TMP)

Useful links: Debugging 101 || NJOE || (Sig image) || Rolla Engineered Solutions, LLC
bradgrafelman is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 12:09 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.