Hi everybody.
I have a select field which is populated with a list of employees from a given location. The value of each option is set to the employee's assigned ID in the database.
What I'm trying to do is create an alert box which will activate when an employee is selected and display additional info about them (salaried, full time, etc.).
I want to be able to do this without cramming the option values with all the info separated by some delimiter. To do this I've created two hidden input fields which will hold the data I want to display.
I'm naming each of these fields dynamically through an ASP loop and setting their values as well.
I would like to retrieve the values in javascript and display them in the alert box using the dynamic field name.
Here's what I'm trying:
The above function is called on an onChange() in the select list. All I get is a null value when I run it and I'm not much of a javascript guru to figure it out myself.
If anyone has any examples of how to do this or suggestions for a better way I am all ears.
Thanks.
I have a select field which is populated with a list of employees from a given location. The value of each option is set to the employee's assigned ID in the database.
What I'm trying to do is create an alert box which will activate when an employee is selected and display additional info about them (salaried, full time, etc.).
I want to be able to do this without cramming the option values with all the info separated by some delimiter. To do this I've created two hidden input fields which will hold the data I want to display.
Code:
<input type="hidden" name="<%= currentEmp %>Rate" value="<%= currentRate %>"></input>
<input type="hidden" name="<%= currentEmp %>Type" value="<%= currentPayType %>"></input>
I'm naming each of these fields dynamically through an ASP loop and setting their values as well.
I would like to retrieve the values in javascript and display them in the alert box using the dynamic field name.
Here's what I'm trying:
Code:
function showRate() {
var f = document.forms.wageChange;
var prempl = f.prempl.value;
var fieldName = prempl+'Rate'
var rate = f.fieldName.value;
alert('Employee Rate: ' + rate);
}
The above function is called on an onChange() in the select list. All I get is a null value when I run it and I'm not much of a javascript guru to figure it out myself.
If anyone has any examples of how to do this or suggestions for a better way I am all ears.
Thanks.