Need Help !! working with Forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sree78
Forum Commoner
Posts: 39
Joined: Tue May 20, 2003 11:38 am

Need Help !! working with Forms

Post 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 :(
User avatar
SantaGhost
Forum Commoner
Posts: 41
Joined: Mon Sep 15, 2003 11:54 am

Post 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
User avatar
SantaGhost
Forum Commoner
Posts: 41
Joined: Mon Sep 15, 2003 11:54 am

Post by SantaGhost »

sorry m8 the code was wrong, try this:

Code: Select all

<?php
if($_POST["q2"] == "Retained for"){
$_POST["q2"] .= " ".$_POST["q2a"]." Years.";
}
?>
sree78
Forum Commoner
Posts: 39
Joined: Tue May 20, 2003 11:38 am

Post by sree78 »

Awesome SantaGhost,

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