/    Sign up×
Community /Pin to ProfileBookmark

populate text boxes based on a selection from a drop down menu

hello,
I am trying to acomplish the above task with a combination of php and javascript. Using the following code i am able to select the info i need and it’s stored in an array $MENU. the drop down menu is populated correctly with the names. how can i extract the necessary data when a selection is made and pass it to the javascript function?

<?php
$query=”SELECT * FROM drivers order by Name”;
$result=mysql_query($query);
$num=mysql_numrows($result);
while ($row = mysql_fetch_object($result)){
$NameN = $row -> Name;
$MENU[$NameN][‘TruckN’] = $row -> Truck;
$MENU[$NameN][‘TrailerN’] = $row -> Trailer;
$MENU[$NameN][‘PhoneN’] = $row -> Phone;
}
mysql_free_result($result);
mysql_close();
?>
<tr class=”bodyClass”>
<td><div align=”center”>
<form name=”form” method=”post” action=”editdriver1.php”>
<?php
echo “<select id=”NameN” name=”NameN” onchange=”update()” class=”a_class”>n”;
echo “<option value=”0″ selected >Choose a driver</option>n”;
foreach ($MENU as $_KEY => $_VAL){
echo “<option value=””.$_KEY.””>”.$_KEY.”</option>n”;
}
echo “</select>n”;
?>
</div></td>
<td><div align=”center”>
<input name=”TruckN” id=”TruckN” type=”text” value=”” class=”a_class” />
</div></td>
<td><div align=”center”>
<input name=”TrailerN” id=”TrailerN” type=”text” value=”” class=”a_class” />
</div></td>
<td><div align=”center”>
<input name=”PhoneN” id=”PhoneN” type=”text” value=”” class=”a_class” />
</div></td>
</tr>
</table>
<p>&nbsp;</p>
<table width=”20%” border=”0″>
<COLGROUP span=”2″ width=”0*
“>
<tr>
<td><div align=”center”>
<input type=”submit” class=”bUgi” name=”Update” value=”Update”>
</form>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Feb 07.2007 — [code=php]<select ..... onchange='MyFunction(this)'>[/code]
×

Success!

Help @murphy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...