954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

populating second drop down list box based on the selection of the first

Hi i m trying to create two drop down list boxes where the second drop downl list box is populated based on the selection of the first one.I have searching the net for days and even the scripts i downloaded don't seem to be working..Can anyone help me plz.....Its urgent...I have deadline approaching....

babydol
Light Poster
25 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

This looks like a javascript problem to me. When is your deadline?

Larry

Larry_b
Newbie Poster
16 posts since Jan 2010
Reputation Points: 12
Solved Threads: 4
 

Hi,

I don't know Javascript all that well. Here is a script I wrote 4 years ago when I was first learning web design. It does what you say you want. Maybe it will give you some ideas.

<HTML>

<head>
<title>Concat two strings</title>

</head>

<form name="demo">

<P>Input1: <input type="text" name="inP1" size=40></p>

<P>Input2: <input type="text" name="inP2" size=40></p>



<p>
<input type="button" name="button2" value="Concatinate Strings" onclick="document.answer.out.value = document.demo.inP1.value + document.demo.inP2.value"> 
</p>
</form>

<form name="answer">

<p>Output: <input type="text" name="out" size=40></p>
</form>
</BODY>
</HTML>
Larry_b
Newbie Poster
16 posts since Jan 2010
Reputation Points: 12
Solved Threads: 4
 
babydol
Light Poster
25 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

Hi,

I think I have something. I think what you want is a self-posting page.
The follow example kind of does close to what you want.

Get rid of the arrays and use the MySQL commands and I think you will have something you can use.

I hope this helps.

Here is that code:

<html>
<head>
</head>
<body>
<?php
$key = $_GET['$key'];
?>

<p>Input animal type:</p>
<form id="form1" action="<?php echo $_SERVER['PHP-SELF'] ?> " method="get">
<p>Input1: <input type="text" name="key" size=40></p>
<p><input type="submit" value="Submit" size=40></p>
</form>

<?php
$key = $_GET['key'];
if (!is_null($key)) {

$row[0] = "Cow";
$row[1] = "Deer";
$row[2] = "Fox";
$row[3] = "Cat";

//$result = mysql_query("SELECT * FROM animal_record WHERE Key='$key'"); 

$i = 0;

echo "<p>Results:</p>";

echo "<form>";
echo "<select name='category'>";

//while($row = mysql_fetch_row($result))

while($i < 4){
   echo "<option>$row[$i]</option>";
   $i += 1;
} /* End while */
echo "</select>";
echo "</form>";

} /* End if */
?>
</form>
</body>
</html>
Larry_b
Newbie Poster
16 posts since Jan 2010
Reputation Points: 12
Solved Threads: 4
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You