Jump to content


Photo

[SOLVED] Required and IF, Else for radio buttons


  • Please log in to reply
3 replies to this topic

#1 TecTao

TecTao
  • Members
  • PipPipPip
  • Advanced Member
  • 144 posts

Posted 21 April 2006 - 06:28 PM

I'm having a real problem writing part of a form that has three radio buttons to select a method of payment.

The three radio buttons are the same name "pay" so that only one can be clicked.

Second, they are required so one out of the three must be clicked to submit.

Third, each radio button has a small text field to put, number attending, amount of check or phone number.

What I need help on is to if one button isn't clicked, then the next or then next but one of the three must be required.

thanks for any help
m
Michael Conway
<a href="http://www.tectaodes...gns.com">TecTao Designs<br>Website Design and Internet Marketing Strategies</a>

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 21 April 2006 - 06:50 PM

You don't need any script for this. Simply have one of the radio buttons selected by default.

<input type="radio" name="pay" id="pay" value="1" selected="selected">Number Attending
<input type="radio" name="pay" id="pay" value="2">Cheque Amount
<input type="radio" name="pay" id="pay" value="3">Phone Nummber

(Odd for radio buttons as tehy don't seem connected - but hey its your form!)

follow me on twitter @PHPsycho

#3 TecTao

TecTao
  • Members
  • PipPipPip
  • Advanced Member
  • 144 posts

Posted 21 April 2006 - 08:43 PM

Thanks for the input, but having the viewer select on of the buttons isn't the challenge. Each radio button has a corresponding text box to fill in something. One of those boxes must be required along with the radio button selection.

So if the pick the first button "number attending" then they have to fill in the corresponding text field.
If the select "Check Amount" then they have to fill in that corresponding text field.
and the same for the last.

None of the radio buttons are selected so they have to select one and fill in the text field info.

Currently I'm using a java script to require text fields, but since I haven't been able to write or locate a java script for radio button selections, I'm considering the required field option using a php if else statement.

Michael Conway
<a href="http://www.tectaodes...gns.com">TecTao Designs<br>Website Design and Internet Marketing Strategies</a>

#4 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 22 April 2006 - 12:11 PM

You cant do it with php unless the text box will appear in the next screen.
You will nee JS for this one. Use the onFocus and onBlur to do this.

Orio.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users