Kane250 Posted September 1, 2009 Share Posted September 1, 2009 This is an odd question. I'm actually doing this in expression engine, but it functions as if I was doing it in php, so I wanted to ask here. I have a page that has a list of events on it. When the page loads, I basically run a for loop that creates hidden divs, each containing their own registration form for the specific event. The div is shown with a button click in javascript, and the user fills out the form, which is dynamically pre-filled with all the information for that specific event. Here is my issue. I am echoing the same form for each event on the page, therefore the input names and id's are duplicated for each form that is created for each event - resulting in tons of duplicate names and id's when i check w3c validation. I'm totally stumped on how one would go about organizing this in a way that can be just as dynamic, but be able to submit the form data with consistent names, without breaking validation. Any ideas or examples anyone can provide? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 1, 2009 Share Posted September 1, 2009 The names are probably not an issue. However, if you are using javascript to make any individual form visible, you would need unique id's anyway or no id's at all, which would result in valid HTML. You would need to post the code that is generating the content (there is likely a way to create unique id's) and post a couple of the validation error messages (or a link to the resulting page if it is on a public web server.) Quote Link to comment Share on other sites More sharing options...
Kane250 Posted September 1, 2009 Author Share Posted September 1, 2009 Yes, you're correct. I am creating unique ID's now by passing the event name as the id, but the names are a problem (according to w3c), and if I create unique names, how will the database I submit to know what is what? I would post code, but it's not actually php, it's expression engine which is run on php I believe, but not the same exactly. Quote Link to comment Share on other sites More sharing options...
mayfair Posted September 1, 2009 Share Posted September 1, 2009 Could you not specify the name as an array? like name="example[]" then reference each one by refering to it directly $_POST["example"][0], $_POST["example"][1] etc? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 1, 2009 Share Posted September 1, 2009 You would need to post one of the sections of the HTML with the error and the corresponding validation error to get any specific help with the problem. Quote Link to comment Share on other sites More sharing options...
Kane250 Posted September 1, 2009 Author Share Posted September 1, 2009 The code really won't help much in this case because it's a general question, plus I am using expression engine, which is like php but simplified. Anyway here is the requested code. {exp:weblog:entries weblog="events" category="24" orderby="eventstartdate" rdf="off" sort="asc"} <div class="hidden"> <input type="hidden" name="eventname" value={eventname}> <input type="text" name="firstName" class="formTextBox" onFocus="clearText(this)" onBlur="clearText(this)" value="First Name" /> <input type="text" name="lastName" class="formTextBox" onFocus="clearText(this)" onBlur="clearText(this)" value="Last Name" /> <input type="text" name="company" class="formTextBox" onFocus="clearText(this)" onBlur= "clearText(this)" value="Company Name" /> <input type="text" name="email" class="formTextBox" onFocus="clearText(this)" onBlur="clearText(this)" value="Email" /> <input type="text" name="phone" class="formTextBox" onFocus="clearText(this)" onBlur="clearText(this)" value="Phone*" /> </div> {/exp:weblog:entries} Basically what's happening here is that a loop is started at the top where the {exp:weblog} tags are, and it is returning a list of all these events I have entered into a pseudo-database kind of system. The loop repeats everything between the opening {exp:weblog} and the closing {/exp:weblog}. Variables look like {eventname}. This is expression engine. I am not asking for help with expression engine, I'm asking for help with logic. I can add php to this if I want to. The result of what I get here is over 15 hidden divs with duplicate text form names. Clearly, to POST any of this info to another page, the form names need to be consistent. If I do the first thing that comes to mind: <input type="text" name="{eventname}"... Then these won't register on the page they need to post to. All the names would be dynamically created, yes, but they would serve no purpose. I can pretty much do anything in expression engine I can do with php, so I am looking for some solid logical way to do this from anyone who has ideas. Thanks! Quote Link to comment Share on other sites More sharing options...
Kane250 Posted September 1, 2009 Author Share Posted September 1, 2009 Could you not specify the name as an array? like name="example[]" then reference each one by refering to it directly $_POST["example"][0], $_POST["example"][1] etc? No, I couldn't because this wouldn't be dynamic anymore. I would have to set reference numbers for each entry in the code, defeating the purpose of what I'm trying to do. But thanks for the suggestion. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 2, 2009 Share Posted September 2, 2009 There is nothing wrong with multiple forms with all the same name="...." attributes. I just put two copies of your form into a valid HTML document and it can be made to validate. Depending on the DOCTYPE about the only real problem is the value in the hidden field is not enclosed in any quotes unless the expression engine supplies those which is unlikely. I certainly hope you are trying to validate the HTML that is being out and not the source code? You have also been asked twice to post some of the validation error messages and the last time you were asked for the actual HTML that was producing a validation error. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.