|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
I have several sets of controls that are repeated. I am trying to use
include files to to the job so as to have my 'tablet' html in one place. <div id="0" class="tablet"> <!-- #include virtual ="tablet.inc" --> </div> <div id="1" class="tablet"> <!-- #include virtual ="tablet.inc" --> </div> <div id="2" class="tablet"> <!-- #include virtual ="tablet.inc" --> </div> I would like the id of each control in the repeated include file to be unique- it doesnt matter what it is called but it must be unique to the page. tablet.inc has elements such as: <input id="blah" name="blahname" onkeyup="somejavascriptfunction(this)" /> which I need to be eg id="blah1" in the first div and id="blah2" in the second or anything along those lines. Any pointers on this much appreciated. Dan |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
On 8 Apr, 11:41, DanWeaver <danofwea...@googlemail.com> wrote:
> I would like the id of each control in the repeated include file to be > unique Well you just can't, so find something else to do. One option is to not use includes, but instead to generate the content dynamically (trivial bit of PHP loop or something). Then it would be easy to generate the ids dynamically too. Alternatively, given that you're already including each include inside a wrapper that has a unique id, then you could re-write the client- side JS or the form handler so as not to require unique ids on each control. Instead they'd have to infer the "identity" of each control from the unique id of their parent, in combination with some sub- selector within this, such as the control type and a class name attached to it that was unique within that parent (but shared with the other includes). Of the two, the first is likely to be easiest. |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
DanWeaver wrote:
> I have several sets of controls that are repeated. I am trying to use > include files to to the job so as to have my 'tablet' html in one > place. > > <div id="0" class="tablet"> > <!-- #include virtual ="tablet.inc" --> > </div> You can't have id="0". An id can't start with a digit. Try id="div0". > <div id="1" class="tablet"> > <!-- #include virtual ="tablet.inc" --> > </div> > > <div id="2" class="tablet"> > <!-- #include virtual ="tablet.inc" --> > </div> If you were using ASP, it would be <% dim n n = 0 %> <div id="div<%=n%>" class="tablet"> <!-- #include virtual ="tablet.inc" --> </div> <% n = n + 1 %> etc. > I would like the id of each control in the repeated include file to be > unique- it doesnt matter what it is called but it must be unique to > the page. > > tablet.inc has elements such as: > > <input id="blah" name="blahname" <input id="blah<%=n%>" name="blahname" > onkeyup="somejavascriptfunction(this)" /> |
|
![]() |
| Outils de la discussion | |
|
|