PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.info.authoring.html > Need unique ids using include file
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Need unique ids using include file

Réponse
 
LinkBack Outils de la discussion
Vieux 08/04/2008, 11h41   #1 (permalink)
DanWeaver
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Need unique ids using include file

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
  Réponse avec citation
Vieux 08/04/2008, 11h57   #2 (permalink)
Andy Dingley
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Need unique ids using include file

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.
  Réponse avec citation
Vieux 08/04/2008, 12h43   #3 (permalink)
Harlan Messinger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Need unique ids using include file

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)" />

  Réponse avec citation
Vieux 08/04/2008, 15h28   #4 (permalink)
DanWeaver
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Need unique ids using include file

Thanks guys,

I will use the asp route- works perfectly!

Dan

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 06h31.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09595 seconds with 12 queries