I am trying to pass values to a text box from a select box. I have variables that I want users to be able to click on and enter in while they are typing text. I got it to work with this code, but it replaces the text that you are typing.
PHP Code:<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
oldvalue = "";
function passText(passedvalue) {
if (passedvalue != "") {
var totalvalue = oldvalue+passedvalue;
document.form.text_1.value = totalvalue;
oldvalue = document.form.text_1.value;
}
}
// End -->
</script>
<form method="post" action="import.php" name="form">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="73%" class="text">1st Paragraph</td>
<td width="27%"> </td>
</tr>
<tr>
<td><textarea cols="40" rows="5" name="text_1" ></textarea></td>
<td><select name="dropdownbox1" style="width:100;" size=4 multiple>
<option value="<%YEAR%>">YEAR</option>
<option value="<%MAKE%>">MAKE</option>
<option value="<%MODEL%>">MODEL</option>
<option value="<%VIN%>">VIN</option>
</select>
</td>
</tr>
<tr>
<td> </td>
<td><input type=button value="<<Insert<<" onClick="passText(this.form.dropdownbox1.options[this.form.dropdownbox1.selectedIndex].value);" style="width:100; height:20;">
</td>
</tr>
</table>
</form>


Reply With Quote

Bookmarks