Click to See Complete Forum and Search --> : forms


slimshady
05-27-2003, 02:29 PM
Hi all i have a question for the real die hard javascript coders

example
<form name=generator>
<input type="text" name=code>
<input type="text" name=defenition>
<input type="text" name=time>
<input type="text" name=code2>
<input type="text" name=defenition2>
<input type="text" name=time2>
</form>

if i type 1 in code i want defenition to display cars and time to display 12:00
Then if i do the same in code 2 i want to display defenition2 to display 12:00 too and time2 to display 12:00 too

i tried to explain my problem as easy as possible i hope you guys understand my problem

Jona
05-27-2003, 02:31 PM
You mean, using onKeyPress="if(this.value==1){this.form.definition.value='12:00';}" ?

Jona

slimshady
05-27-2003, 03:08 PM
yes but onkeypress it has to change 2 field values instead of one like the example you give

Jona
05-27-2003, 03:43 PM
Do you need more help? Or did I answer your question? You should be able to figure it out with the example I gave you...

Jona

slimshady
05-27-2003, 04:05 PM
Thank you very much it works...
but now i have to add this line (and 80 of em) at the end of a input field
i wrestled with it to put it in a function and let every field check values in the function... can you please...
i just cant do it

Jona
05-27-2003, 04:18 PM
Use a for() loop to go through all of the values so that it will automatically do it for you. That's what I'd do.

Jona

slimshady
05-27-2003, 04:27 PM
so

<td><input type=text name=check size=6 onblur="if(this.value==1){this.form.amount.value='12.00'; this.form.presented.value='cars';}else if(this.value==2){this.form.amount.value='13.00'; this.form.presented.value='bikes';}">

will become
<script langu.......
function check()
for (this.value==1){this.form.amount.value='12.00'; this.form.presented.value='cars';}else if(this.value==2){this.form.amount.value='13.00'; this.form.presented.value='bikes';}">
</script>
<td><input type=text name=check size=6 onblur="check()">

am i right?

Jona
05-27-2003, 10:30 PM
Actually, if each set of text fields has its own set of values, you probably won't be able to do it that way. You'll have to code them all on your own--manualliy.

Jona

slimshady
05-28-2003, 02:43 PM
ok the page is BIG but it runs fast and it works perfect...
thank you for your help jona...
greetingz slimshady (i guess words are a motherf*cker)