All:
This is what I want to happen:
1. When a user would fill out this form, they would first have to choose a company from a select menu preloaded with values.
2. Once the user has made a selection, somehow the form is generated with values from another table in the database based upon this selection.
I found a semi solution, but unfortunately one would have to manually load all values in the option value and hit "tab" to work. Also once manually loaded the fields have to be separated in order for the script to read each individual value. "-"
The only part I don't like is "manually loading the option value in the form".
It would be lovely if the option value would auto fill dynamically based upon what's in the db for that field.
Here's the semi-solution:
Here's the form part...
the result in this example is all 1's.
Thanks in advance.
BG
This is what I want to happen:
1. When a user would fill out this form, they would first have to choose a company from a select menu preloaded with values.
2. Once the user has made a selection, somehow the form is generated with values from another table in the database based upon this selection.
I found a semi solution, but unfortunately one would have to manually load all values in the option value and hit "tab" to work. Also once manually loaded the fields have to be separated in order for the script to read each individual value. "-"
The only part I don't like is "manually loading the option value in the form".
It would be lovely if the option value would auto fill dynamically based upon what's in the db for that field.
Here's the semi-solution:
Code:
...
<head>
<script>
function fillProfileFields(){
var Profile = document.getElementById("companyid");
if(Profile.value.length > 0){
var ProfileElements = Profile.value.split("-");
document.getElementById("city").value = ProfileElements[0];
document.getElementById("state").value = ProfileElements[1];
document.getElementById("zip").value = ProfileElements[2];
document.getElementById("overview").value = ProfileElements[3];
document.getElementById("locations").value = ProfileElements[4];
}
}
</script>
</head>
Here's the form part...
Code:
<span>
<select name="companyid" id="companyid" onChange='fillProfileFields();'>
<option selected value="">-- select a company --</option>
<option value="">---------</option>
<option value="1-1-1-1-1-1-1-1-1-1-1-1-1">Company 1</option>
<option value="2-2-2-2-2-2-2-2-2-2-2-2-2">Company 2</option>
<option value="3-3-3-3-3-3-3-3-3-3-3-3-3">Company 3</option> </select><label>Company Name</label></span>
the result in this example is all 1's.
Thanks in advance.
BG