Page 1 of 1

Need Help !! working with Forms

Posted: Tue Sep 16, 2003 9:21 am
by sree78
Hi,


I am creating a form using PHP and I am stuck at this one:-

Code: Select all

What would you like to do with the document?
  
Radio Option 1
==========
<input type="radio" name="q2" tabindex="2" id="02" value="Destroy" />Destroyed 

<br />

Radio Option 2
==========
<input type="radio" name="q2" tabindex="2" id="02" value="Retain" />Retained 

<br />

Radio Option 3
==========
<input type="radio" name="q2" tabindex="2" id="02" value="Retained for" />Retained for 

<input type="text" name="q2a" size="10" tabindex="3" id="03" />years
The problem is with the third radio button, it has another text box asking user to enter the #of years.

So if the user selects Radio Option 3 I can get the php to pass the form variable only like "Retain for 'whatever the number the user specified' " e.g Retain for 10 ..... but I want the variable to add the years at the back to complete the sentence in the confirmation page.

Any help is highly appreciated.... need to complete this form by the end of the day. Thanks a lot in advance :(

Posted: Tue Sep 16, 2003 9:29 am
by SantaGhost
add to the top of confirmation page:

Code: Select all

<?php
if(isset($_POST["q2a"])){
$_POST["q2"] .= " ".$_POST["q2a"]." Years.";
}
?>
hope it helps, it allways helps to post the page in question to clarify

Posted: Tue Sep 16, 2003 10:50 am
by SantaGhost
sorry m8 the code was wrong, try this:

Code: Select all

<?php
if($_POST["q2"] == "Retained for"){
$_POST["q2"] .= " ".$_POST["q2a"]." Years.";
}
?>

Posted: Tue Sep 16, 2003 11:07 am
by sree78
Awesome SantaGhost,

This code works like a charm... thanks a lot....