D
dan
I have a script that selects a value in an option in a selection list
according to how many letters were entered in an input box. I have it
working but I am limited to what I can name the form fields because
they are dynamically created by a PHP script.
I can get it to work with simple name but not with names outputted by
the script. Is there a change I can make to the JavaScript so I can
use the dynamic names?
Simple name = 'letter_number'
Dynamic name = 'id[txt_3]'
-----------------------------
EX w/ simple input names
WORKING:
<form action="#" name="form_name">
Text Insert:
<input type="text" name ="text_name" size="6" maxlength="6" value=""
onChange="document.form_name.letter_number.value=document.form_name.text_name.value.length+6;"
onBlur="document.form_name.letter_number.value=document.form_name.text_name.value.length+6;">
<br>
# of letters:
<select name="letter_number">
<option value="7">1</option>
<option value="8">2</option>
<option value="9">3 (+$4.00)</option>
<option value="10">4 (+$8.00)</option>
<option value="11">5 (+$12.00)</option>
<option value="12">6 (+$16.00)</option>
</select>
</form>
---------------------------
w/ outputted dynamic names (just need to get it working with this type
of name)
NON WORKING:
<form action="#" name="form_name">
Text Insert:
<input type="text" name ="id[txt_3]" size="6" maxlength="6" value=""
onChange="document.form_name.id[5].value=document.form_name.id[txt_3].value.length+6;"
onBlur="document.form_name.id[5].value=document.form_name.id[txt_3].value.length+6;">
<br>
# of letters:
<select name="id[5]">
<option value="7">1</option>
<option value="8">2</option>
<option value="9">3 (+$4.00)</option>
<option value="10">4 (+$8.00)</option>
<option value="11">5 (+$12.00)</option>
<option value="12">6 (+$16.00)</option>
</select>
</form>
according to how many letters were entered in an input box. I have it
working but I am limited to what I can name the form fields because
they are dynamically created by a PHP script.
I can get it to work with simple name but not with names outputted by
the script. Is there a change I can make to the JavaScript so I can
use the dynamic names?
Simple name = 'letter_number'
Dynamic name = 'id[txt_3]'
-----------------------------
EX w/ simple input names
WORKING:
<form action="#" name="form_name">
Text Insert:
<input type="text" name ="text_name" size="6" maxlength="6" value=""
onChange="document.form_name.letter_number.value=document.form_name.text_name.value.length+6;"
onBlur="document.form_name.letter_number.value=document.form_name.text_name.value.length+6;">
<br>
# of letters:
<select name="letter_number">
<option value="7">1</option>
<option value="8">2</option>
<option value="9">3 (+$4.00)</option>
<option value="10">4 (+$8.00)</option>
<option value="11">5 (+$12.00)</option>
<option value="12">6 (+$16.00)</option>
</select>
</form>
---------------------------
w/ outputted dynamic names (just need to get it working with this type
of name)
NON WORKING:
<form action="#" name="form_name">
Text Insert:
<input type="text" name ="id[txt_3]" size="6" maxlength="6" value=""
onChange="document.form_name.id[5].value=document.form_name.id[txt_3].value.length+6;"
onBlur="document.form_name.id[5].value=document.form_name.id[txt_3].value.length+6;">
<br>
# of letters:
<select name="id[5]">
<option value="7">1</option>
<option value="8">2</option>
<option value="9">3 (+$4.00)</option>
<option value="10">4 (+$8.00)</option>
<option value="11">5 (+$12.00)</option>
<option value="12">6 (+$16.00)</option>
</select>
</form>