Dynamic Selection from a radio button to a list box

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
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Dynamic Selection from a radio button to a list box

Post by Kingo »

Hello,
I'm trying to implement the following.
I should have 4 radio buttons.
If i select the 1st radio button i should get a selection of items in a list box, if i select a second radio buton i should get another selection of items in the list and so on. I donot know if i have to do it using Java Script or PHP. ANy help is really appreciated.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

How about divulding some code?
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Post by Kingo »

Here is the code.

Code: Select all

<html>
<head>
<title>Dynamic Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div align="center">
  <p><strong><font size="2" face="Arial, Helvetica, sans-serif">Please Enter the 
    Details</font></strong> </p>
  <form name="form1" method="post" action="">
    
    <p align="left">&nbsp;</p>
    <table width="40%" border="1" align="left" cellpadding="0" cellspacing="0">
      <tr> 
        <td width="50%"><strong><font size="2" face="Arial, Helvetica, sans-serif">First 
          Name</font></strong></td>
        <td width="50%"> <input type="text" name="middle"> </td>
      </tr>
      <tr> 
        <td><strong><font size="2" face="Arial, Helvetica, sans-serif">Middle</font></strong></td>
        <td><input type="text" name="textfield2"></td>
      </tr>
      <tr> 
        <td><strong><font size="2" face="Arial, Helvetica, sans-serif">Last Name</font></strong></td>
        <td><input name="lname" type="text"></td>
      </tr>
    </table>
    <p align="left">&nbsp; </p>
    <p align="left"><br>
    </p>
    <p align="left"><strong>Select One:</strong></p>
    <p align="left"> 
      <input type="radio" name="radiobutton" value="HS">
      <font size="2" face="Arial, Helvetica, sans-serif"><strong>HS</strong></font></p>
    <p align="left"><font size="2" face="Arial, Helvetica, sans-serif"><strong> 
      <input type="radio" name="radiobutton" value="MS">
      MS</strong></font></p>
    <p align="left"><font size="2" face="Arial, Helvetica, sans-serif"><strong> 
      <input type="radio" name="radiobutton" value="ES">
      ES </strong> </font></p>
    <p align="left"><font size="2" face="Arial, Helvetica, sans-serif">Please 
      select your Locality 
      <select name="select">
      </select>
      </font></p>
    <p align="left"> 
      <input type="submit" name="Submit" value="Submit">
    </p>
    <p align="left">&nbsp; </p>
  </form>
  <p align="left">&nbsp;</p>
</div>
</body>
</html>

If I selct the the radio button HS, i should get a list with the items&#123; blank,HS1,HS2,HS3,HS4&#125;
If I selct the the radio button MS, i should get a list with the items&#123; blank,MS1,MS2,MS3,MS4&#125;
If I selct the the radio button ES, i should get a list with the items&#123; blank,ES1,ES2,ES3,ES4&#125;
Thanx for your help
Last edited by Kingo on Mon Jun 14, 2004 8:40 am, edited 1 time in total.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Edit your post and use

Code: Select all

-tags around it.
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post by fastfingertips »

You should use JavaScript because if you are using PHP you will have to resubmit the page and this is not recommended (traffic, time lost etc).

And i hate this tag: <script language="php"></script>
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Post by Kingo »

Thanx,
Can any one help me out with one. DO i need to use the arrays. Any help with coding is appreciated.
Thanx
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Post by Kingo »

Can any one help me out .
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you'll need arrays, document.write's, if's... and a few other things probably.. like a function..
Post Reply