hi all,
I'm writing a function that, say, loop through input fields in a form
and set default values to it. Some fields are dependent thus I have
some onChange scripts to kick off corresponding actions to those
fields.
<form name="test">
<input type="text" name="text1">
<input type="text" name="text2" onChange="text1 .value+=this.va lue;">
<input type="text" name="text3" onChange="doSom ething();">
</form>
<script language="JavaS cript">
function setDefault(form ) {
var fields = form.elements;
for (var i=0; i<fields.length ; i++) {
// for each field, somehow get a default value and set it.
}
}
</script>
......
[OnChange] catches only browser actions as far as I understand. That
means when I set a value to "text2" via the method, the corresponding
action isn't triggered.
I can get the actions of a corresponding field by:
var actn = field.onchange;
alert( actn );
which shows:
anonymous() {
doSomething();
}
Despite being able to get all those actions and store them in a
variable, I don't know how to execute them. Do anyone has a clue?
Thanks very much
George
I'm writing a function that, say, loop through input fields in a form
and set default values to it. Some fields are dependent thus I have
some onChange scripts to kick off corresponding actions to those
fields.
<form name="test">
<input type="text" name="text1">
<input type="text" name="text2" onChange="text1 .value+=this.va lue;">
<input type="text" name="text3" onChange="doSom ething();">
</form>
<script language="JavaS cript">
function setDefault(form ) {
var fields = form.elements;
for (var i=0; i<fields.length ; i++) {
// for each field, somehow get a default value and set it.
}
}
</script>
......
[OnChange] catches only browser actions as far as I understand. That
means when I set a value to "text2" via the method, the corresponding
action isn't triggered.
I can get the actions of a corresponding field by:
var actn = field.onchange;
alert( actn );
which shows:
anonymous() {
doSomething();
}
Despite being able to get all those actions and store them in a
variable, I don't know how to execute them. Do anyone has a clue?
Thanks very much
George
Comment