slash in a form item name

P

Pierre-Yves

Hello,

I have to change the value of a form item wich contains slashes in its name
(ie: <input name="hello/how/are/you" ....>)
I know it's crazy but the form is dynamically generated by a 3rd party tool,
so I don't have any control on it.

With this piece of code I can see the item names :

function tst() {
for (i=0; i<document.tst.elements.length;i++) {
alert(document.tst.elements.name);
}
}

But how can I change its value ?

Thanks in advance,
Pierre-Yves.
 
R

Richard Cornford

Pierre-Yves said:
I have to change the value of a form item wich contains slashes
in its name (ie: <input name="hello/how/are/you" ....>)
I know it's crazy but the form is dynamically generated by a
3rd party tool, so I don't have any control on it.

With this piece of code I can see the item names :

function tst() {
for (i=0; i<document.tst.elements.length;i++) {
alert(document.tst.elements.name);
}
}

But how can I change its value ?


See the group's FAQ, particularly quick answers 4.25 and 4.39 (and
linked resources).

<URL: http://jibbering.com/faq/ >

The result will resemble:-

document.forms['tst].elements['hello/how/are/you'].value = x;

(but it is best to use the FAQ references and understand why)

Richard.
 
P

Pierre-Yves

Nice FAQ!
it solved my problem, thanks !

Richard Cornford said:
Pierre-Yves said:
I have to change the value of a form item wich contains slashes
in its name (ie: <input name="hello/how/are/you" ....>)
I know it's crazy but the form is dynamically generated by a
3rd party tool, so I don't have any control on it.

With this piece of code I can see the item names :

function tst() {
for (i=0; i<document.tst.elements.length;i++) {
alert(document.tst.elements.name);
}
}

But how can I change its value ?


See the group's FAQ, particularly quick answers 4.25 and 4.39 (and
linked resources).

<URL: http://jibbering.com/faq/ >

The result will resemble:-

document.forms['tst].elements['hello/how/are/you'].value = x;

(but it is best to use the FAQ references and understand why)

Richard.
 

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,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top