0

I know this is simple, but I can't get it working. I'm hoping someone here can help.

First off, this is part of a web app for iOS.

Okay, I have a list of items:

Room Type: <select id="isoList" name="isoList">
<option></option>
<option value="20">ISO 8 Life Sciences Low Use</option>
<option value="25">ISO 8 Life Sciences Med Use</option>
<option value="30">ISO 8 Life Sciences High Use</option>
</select>

I need to have the user select the room type, then pass the option value - as a var - to another function that uses the var in a calculation.

Here's the script I have to far. My form is named airflow...

function isoChange()
{
var isoChange = document.airflow("isoList");
var airChanges = isoChange.options[isoList.selectedIndex].value;
}

Now I want to pass airChanges to this function...

function calcAF(airChanges)
{
var length = document.airflow.length.value; //length
var width = document.airflow.width.value; //width
var height = document.airflow.height.value; //height
var changes = airChanges; // hourly air changes
}

From there the calcAF function will use the var in various math formulae.

I've got it to work if I get the user to tell me airChanges, but it breaks when I try to get the airChanges from a drop down list.

4

2 回答 2

0

Maybe I don't understand the problem, but from what I understand, the isoChange function should look like this:

function isoChange()
{
   var isoChange = document.airflow("isoList");
   var airChanges = isoChange.options[isoList.selectedIndex].value;
   calcAF(airChanges);
}
于 2012-11-12T19:37:14.507 回答
0

The onchange event of a <select> element will be triggered every time the selection changes

document.getElementById('isoList').onchange = function() { 
    calcAF(this.value);
}​

Working example here: http://jsfiddle.net/hba9a/5/

于 2012-11-12T19:42:29.240 回答