seems like a simple problem, at least to describe
i wwould like to create a simple script that has a drop down menu that when a value is chosen automaically updates the associated variable
say...
i have a drop down for.. weight, and want to use that number for calculation of body mass index
this i believe can be done with ajax
update variable automaticaly based on a drop down
Moderator: General Moderators
Re: update variable automaticaly based on a drop down
...and I believe it can be done without PHP.
Code: Select all
<html><body>
<script type="text/javascript">
function updateLabel(value) {
document.getElementById("label").innerHTML = "3 * " + value + " = " + (3 * value) + ".";
}
</script>
<p id="label">You haven't picked a number yet.</p>
<p><select onchange="updateLabel(this.value);">
<option value="1">1</option>
<option value="5">5</option>
<option value="13">13</option>
<option value="77">77</option>
</select></p>
</body></html>