View Full Version : with same IDs(per BLOCK), but in a time one only display:block the other two display:
lse123
04-25-2013, 02:55 PM
May have in a web page HTML or HTML 5,... 3 DIV BLOCKS within each a <form> etc tags, with same IDs(per BLOCK), but in a time one only display:block the other two display:none (in a time)... can have this many IDs the same???
I'm not completely sure what you are asking. If I understand correctly, NO, element id attributes must be unique. Only one element may have any given id; display/visibility doesn't matter.
If this is not what you are asking, please explain your question more clearly.
lse123
04-25-2013, 04:58 PM
YES THAT MEAN... Well i have to use other Technics, so as IDs must be unique ALL either in display:none/block, like other client or server techniques... process one form from 3 different forms(one visible), like in a rent a car project having:
booking confirm page after a quote:
book without Register
book and Register
book and Social Register
correct?
Will you only process one of the three forms?
Will you *ever* need to process more than one at the same time?
If they are exclusive (meaning you'll only ever process one of the three), then you can give the forms / form inputs the same name attributes (names can be the same; ids can not).
another option would be to simply have one form, and hide the inputs you don't need. for example (IIUC),
<form id="myform">
<fieldset id="booking">
<legend>Booking</legend>
<p>This section is always visible.</p>
<label>book: <input name="book"></label>
</fieldset>
<fieldset id="register">
<legend>Register</legend>
<p>This section is visible if the user is going to register,
and hidden otherwise.</p>
<label>register: <input name="register"></label>
</fieldset>
<fieldset id="social-register">
<legend>Social register</legend>
<p>This section is visible if the user is going to "social" register,
and hidden otherwise.</p>
<label>social: <input name="social"></label>
</fieldset>
<label>Submit the form:
<input type="submit" name="myform-submit" value="submit">
</label>
</form>
lse123
04-25-2013, 05:36 PM
yes since all results are a booking,... only one form used ever and processed....
if instead of "id" use "name" (PHP looks "name" attribute only in Post super global correct?) then in javascript use getElementByName("nameAttributeValue').value, correct?
(PHP looks "name" attribute only in Post super global correct?)
correct
then in javascript use getElementByName("nameAttributeValue').value, correct?
you *could*, but since names are not unique, you'd need to figure out which one you want (since getElementsByName returns a list, not an individual item).
You can use ids and names together - use the id for javascript functionality, and use the name for processing the form in PHP.
lse123
04-25-2013, 08:04 PM
is any way use keyword this with form.nameAttribute.value to get value?
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.