Object names with square bracket

N

Nalpo

Hi,
i want to update several Textboxes by reading the value of another
Box. For that i use the following small script:

<form name="form1" method="POST">
<input type="text" name="xx" value ="1"
onBlur="document.form1.tex1.value=document.form1.xx.value"><br>
<input name="tex1" type="text" size=16 maxlength=80 value="1">
</form>

Everything works fine, but for my PHP-Script i need square brackets [
]. If i try to add them, my Script got an error:

<form name="form1" method="POST">
<input type="text" name="xx" value ="1"
onBlur="document.form1.tex[1].value=document.form1.xx.value"><br>
<input name="tex[1]" type="text" size=16 maxlength=80 value="1">
</form>

Whats wrong?

Thanks!
 
L

lallous

Hello

This is a common issue.

Access the named object from javascript as:

theForm["elementName"].value = xyz .... or
theForm.elements["elementName"].value = "asdasda";

Example:

theForm["tex[1]"].value = xxxxxxxxxxxx................

HTH,
Elias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top