Forum Moderators: open

Message Too Old, No Replies

duplicating div's with input fields & buttons question.

Are input elements local or global.

         

nelsonm

12:05 am on Aug 15, 2008 (gmt 0)

10+ Year Member



I duplicated an html div containing input fields and buttons several times as part of a html form thats processed by a php mailform script upon form submission. Only one div is visible at a time, the others are hidden.

The question is whether the input variable, button, checkbox and radio button names and id's within the each div are local to the div or are they global?

I suspect they are global throughout the html body and i'll have to add a suffix number to each div's input variable, button, checkbox and radio button names and id's so each div has a unique set of variables.

heres an example:


<div id=div1>
<input type="text" id=text1
<input type="button" id=button1
<input type="checkbox" id=checkbox1
<input type="radio" id=radio1
</div>

<div id=div2>
<input type="text" id=text2
<input type="button" id=button2
<input type="checkbox" id=checkbox2
<input type="radio" id=radio2
</div>

<div id=div3>
<input type="text" id=text3
<input type="button" id=button3
<input type="checkbox" id=checkbox3
<input type="radio" id=radio3
</div>

DrDoc

12:54 am on Aug 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IDs must be unique to the document.

nelsonm

1:05 am on Aug 15, 2008 (gmt 0)

10+ Year Member



Just the Id's - not the names?

csuguy

2:43 am on Aug 15, 2008 (gmt 0)

10+ Year Member



there are no names in your code. If your referring to the individual id's that you've put for each id attribute - then yes you need a unique name/id for each id attribute.

nelsonm

3:06 am on Aug 15, 2008 (gmt 0)

10+ Year Member



thanks,

the code was just an example but "name=" would be included.

DrDoc

6:05 am on Aug 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Names need not be unique. Just make sure you test extra well to ensure that the right field data is communicated as expected. I would opt for unique names as well.