Page 1 of 1

Dynamic Selection from a radio button to a list box

Posted: Mon Jun 14, 2004 8:04 am
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.

Posted: Mon Jun 14, 2004 8:09 am
by patrikG
How about divulding some code?

Posted: Mon Jun 14, 2004 8:22 am
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

Posted: Mon Jun 14, 2004 8:27 am
by patrikG
Edit your post and use

Code: Select all

-tags around it.

Posted: Mon Jun 14, 2004 8:58 am
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>

Posted: Mon Jun 14, 2004 9:07 am
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

Posted: Mon Jun 14, 2004 10:21 am
by Kingo
Can any one help me out .

Posted: Mon Jun 14, 2004 11:31 am
by feyd
you'll need arrays, document.write's, if's... and a few other things probably.. like a function..