Harry
07-11-2003, 12:58 AM
Ok. This what I have so far:
when I select an option in the drop-down menu,
the description is displayed in the textarea.
The code below works fine but if I add the
option "multiple" to my select statement then
I need to change my select name to "one[]" so
PHP will recognize it as an array.
When I do this and change the name to "one[]" in
my javascript, nothing will display in the
textarea.
Does anyone have an idea about how I might
accomplish this?
I just started programming Javascript
about 3 weeks ago so any help would be
greatly appreciated
Thank you
Harry
<form name='forma'>
<fieldset><legend $lft>$font4w<strong>Asset Management$ef</legend>
<table background='5.jpg' width='100%'>
<tr>
<td $lft><select name='one' size='1' onChange='show_one()'>";
$role="AM";
get_it($role);
echo "
<select></td>
<td $rgt>
<textarea rows=2 cols=60 wrap='virtual' name='text_one'></textarea>
</td>
</tr>
</table>
</fieldset>";
?>
<script language="javascript">
var am=document.forma
var am_desc=new Array()
am_desc[0]="<?php echo $am_desc[0] ?>"
am_desc[1]="<?php echo $am_desc[1] ?>"
am_desc[2]="<?php echo $am_desc[2] ?>"
am_desc[3]="<?php echo $am_desc[3] ?>"
am_desc[4]="<?php echo $am_desc[4] ?>"
am.text_one.value=am_desc[am.one.selectedIndex]
function show_one()
{
am.text_one.value=am_desc[am.one.selectedIndex]
}
</script>
</form>
This is where I load my options from a database:
The info in the select box is variable $rn
and the description is variable $ad which I load
into an array.
<?php
function get_it($role)
{
$am_desc=array();
global $am_desc;
$i=0;
$qry="select * from ps_access where access_code='$role'";
$result=mysql_query($qry);
echo mysql_error();
while(list($rn, $ad)=mysql_fetch_row($result))
{
if($role=="AM")
$am_desc[$i]=$ad;
echo "<option value='$rn'>$rn</option>";
$i++;
}
mysql_close($link);
}
?>
when I select an option in the drop-down menu,
the description is displayed in the textarea.
The code below works fine but if I add the
option "multiple" to my select statement then
I need to change my select name to "one[]" so
PHP will recognize it as an array.
When I do this and change the name to "one[]" in
my javascript, nothing will display in the
textarea.
Does anyone have an idea about how I might
accomplish this?
I just started programming Javascript
about 3 weeks ago so any help would be
greatly appreciated
Thank you
Harry
<form name='forma'>
<fieldset><legend $lft>$font4w<strong>Asset Management$ef</legend>
<table background='5.jpg' width='100%'>
<tr>
<td $lft><select name='one' size='1' onChange='show_one()'>";
$role="AM";
get_it($role);
echo "
<select></td>
<td $rgt>
<textarea rows=2 cols=60 wrap='virtual' name='text_one'></textarea>
</td>
</tr>
</table>
</fieldset>";
?>
<script language="javascript">
var am=document.forma
var am_desc=new Array()
am_desc[0]="<?php echo $am_desc[0] ?>"
am_desc[1]="<?php echo $am_desc[1] ?>"
am_desc[2]="<?php echo $am_desc[2] ?>"
am_desc[3]="<?php echo $am_desc[3] ?>"
am_desc[4]="<?php echo $am_desc[4] ?>"
am.text_one.value=am_desc[am.one.selectedIndex]
function show_one()
{
am.text_one.value=am_desc[am.one.selectedIndex]
}
</script>
</form>
This is where I load my options from a database:
The info in the select box is variable $rn
and the description is variable $ad which I load
into an array.
<?php
function get_it($role)
{
$am_desc=array();
global $am_desc;
$i=0;
$qry="select * from ps_access where access_code='$role'";
$result=mysql_query($qry);
echo mysql_error();
while(list($rn, $ad)=mysql_fetch_row($result))
{
if($role=="AM")
$am_desc[$i]=$ad;
echo "<option value='$rn'>$rn</option>";
$i++;
}
mysql_close($link);
}
?>