Results 1 to 10 of 10
Thread: coordinating field names
Aug 23, 2013, 10:37 #1
- Join Date
- Jun 2008
- Madison, WI
- 34 Post(s)
- 2 Thread(s)
coordinating field names
I've been working on a dynamic form which uses .js to allow users to add field sets. my strategy is/ was to have a master object ( a field-set) that is cloned and appended or deleted from the DOM. the name all fields are given as an array, eg.: 'fieldName', upon submission that means i would be able to enter the information into the DB in the same order as the user had it on the form ; 'fieldName would be the fist fieldset, 'fieldName the second, 'fieldName the third, and so forth. ALSO, this way data from all fieldsets would be coordinated relative to the fieldset, eg.: 'otherFiled' woudl also submit as 'fieldName would be the fist fieldset, 'fieldName the second, 'fieldName the third, and so forth.
1) Radio butons fields are linked though ALL field sets. I should have seen that one coming , since they all share the same name ( I really thought the ") was going to make a difference , but I was wrong
2) Checkboxes screw the count coordination , since checkboxes are not submitted when unchecked and I was counting on all my field names being an array of fried directly mapped to whichever field set they came from. :/ so what I am saying is if I had 5 fieldsets and the checkbox on #3 is not checked my form submits an array containing 4 values; in this example because checkbox #3 is missing, #4 will come in as the 3rd array element, and #5 as the forth.. see no longer synchronized. I understand that this the nature of checkboxes but I was hoping someone my know a trick around this.
I actually was pondering using a hidden field to send a dummy value, <input type=hidden name="x" value="blah" > <input checkbox=hidden name="x" value="1" > but since I am using an array that wont work as the hidden input would always be passed and increase the array pointer, rather than overriding the value for the checkbox field
I suppose this could be a gemeal HTML question as much as .js. But I thought that if there was no way to achieve this with plain HTML, i coudl use .js to do something to keep the fieldnames matched to the order that they are presented on screen. If that makes sense?
I fear I have painted myself into a corner here and would appreciate any suggestions.Tips for better/ faster SitePoint forum answers
Brilliant ideas, elegant execution.
Graphic Design, Art Direction, Copywriting and Web Design.