<TR>
<TD align="right" valign="top" style="width:75px">
Title:
</TD>
<TD valign="top" colspan="5" style="width:350px">
<?
$query2="SELECT year FROM systems";
$result2 = mysql_query ($query2);
echo "<select id='year' style='background:#FFFF99; width:340px' name=year value='' onchange='window.location.reload()'>Title</option>";
while($nt2=mysql_fetch_array($result2)){
echo "<option value=$nt2[year]>$nt2[year]</option>";
}
echo "</select>";
?>
</TD>
<TD align="right" valign="top" style="width:75px">
Landmark:
</TD>
<TD valign="top" style="width:340px" colspan="2" rowspan="3">
<TEXTAREA style="background:#FFFFFF; width:340px" name="landmark" rows="3">
</TEXTAREA>
</TD>
</TR>
<TR>
<TD align="right" valign="top" style="width:75px">
Mfr:
</TD>
<TD valign="top" colspan="5" style="width:350px">
<?
$year = $_GET[year];
$query3="SELECT system FROM systems WHERE year = '$year'";
$result3 = mysql_query($query3);
$nt3=mysql_fetch_assoc($result3);
echo "<INPUT style='background:#FFFF99; width:340px' type='text' name='mfr' id='mfr' value='$nt3[system]'> </INPUT>";
?>
</TD>
</TR>
textfield value changes based on dropdown selection with PHPTrying to get Mfr to change its values based on title from dropdown
Page 1 of 1
5 Replies - 3975 Views - Last Post: 15 April 2010 - 04:34 PM
#1 Guest_JustinB*
textfield value changes based on dropdown selection with PHP
Posted 15 April 2010 - 11:27 AM
Please don't pay much attention to variable names.
Replies To: textfield value changes based on dropdown selection with PHP
#2
Re: textfield value changes based on dropdown selection with PHP
Posted 15 April 2010 - 02:56 PM
PHP is processed, then data sent to the user. This means that PHP cannot change drop downs until the next page refresh. You either want to use ajax or straight javascript.
#3 Guest_Justinb*
Re: textfield value changes based on dropdown selection with PHP
Posted 15 April 2010 - 03:20 PM
im having the page refresh with an onchange function in the dropdown
#4
Re: textfield value changes based on dropdown selection with PHP
Posted 15 April 2010 - 03:53 PM
I think it's because your reloading the page. What you need to do is use ajax to call a Javascript file that pulls selectedIndex of the drop downs and then send that value to a PHP file to process the query. The result is returned and the AJAX can populate the form appropriately.
#5
Re: textfield value changes based on dropdown selection with PHP
Posted 15 April 2010 - 04:17 PM
search for "chained dropdowns". jQuery or prototype have useful libraries for taking the pain out of ajax objects.
#6
Re: textfield value changes based on dropdown selection with PHP
Posted 15 April 2010 - 04:34 PM
Page 1 of 1
|
|

New Topic/Question
Reply
MultiQuote










|