digitalgod Posted August 16, 2008 Share Posted August 16, 2008 Ok this might be a bit hard to explain but it I'll give it my best shot! I have a panel where a user can create questions, and he can add as many questions as he wants. Each question has the option to include images as answers, those images are taken from categories, so for example a user can choose to include these categories; carpet, wood, stone. He can also create his own drop downs for each questions by simply typing whatever value he wants and it will add itself. All this is already done, the user can simply press on Add Another Question and fill it up again, my only problem is how to collect all of that data. I could make all of the elements arrays but I don't think that would work because I still need to collect all of the image categories for each question as well as all of the drop down (if a drop down is created ) entries for each question. I just need help with the logic behind all of this, I can't collect all of the information for 1 question quite easily but when more questions are added I'm not exactly sure how to collect them. Quote Link to comment https://forums.phpfreaks.com/topic/119995-need-help-with-form-logic-and-dynamically-generated-content/ Share on other sites More sharing options...
ignace Posted August 16, 2008 Share Posted August 16, 2008 question, answer (textfield) question, answer1, answer2, answer3 (radio) question, answer1, answer2, answer3 (select) question, answer1, answer2, answer3 (select, multiple) question, answer1, answer2, answer3 (checkbox) types (id, type) // values (1, 'text'), (2, 'radio'), (3, 'select'), (4, 'checkbox'), (5, 'select multiple') questions (id, question) answers (id, question_id, answer) question_to_answer (question_id, answer_id, type_id) don't know for certain but an abstract factory would do nice things here Quote Link to comment https://forums.phpfreaks.com/topic/119995-need-help-with-form-logic-and-dynamically-generated-content/#findComment-618117 Share on other sites More sharing options...
digitalgod Posted August 16, 2008 Author Share Posted August 16, 2008 hmm well what I meant was processing the form here I'll give you an example of what the form looks like <form name="newcatalog" id="newcatalog" action="" class="forms" method="post"> <h2>Question 1</h2> <li> <label for="title">Question<em>*</em></label> <input type="text" name="title" id="title" class="text" /> </li> <div id="multiple_categories"> <li> <label for="multiple image categories">Multiple Image Categories</label> <input type="checkbox" name="categories" id="categories" /> </li> <li id="add-categories" style="display:none"> <label for="multiple image categories">Add Categories</label> <ul id="browser" class="filetree"> <?php display_categories(); ?> </ul> </li> <li id="categories-added" style="display:none"><label for="Categories Added">Categories Added</label> <select id="all_categories" name="all_categories" multiple="multiple" height="5"> </select> </li> </div> <li> <label for="Create Drop-Down">Create Drop-Down</label> <input type="checkbox" name="dropdown" id="dropdown" /> </li> <li> <label for="Add value">Add value</label> <input type="text" name="addToDropdown" id="addToDropdown" /><a href="#"><img src="images/add.gif"></a> <select name="dd_values" id="dd_values"> </select> </li> <li><label for="submit"></label> <button name="add" id="add">Add another question</button><input class="submit" type="submit" value="Create catalog"/> </li> </form> For now when a user adds a category it goes in all_categories for him to see and when he adds an option for the drop down it goes in dd_values. I need to be able to collect all of that information for several questions (depending on how many questions were added) So how should I collect all that information? Quote Link to comment https://forums.phpfreaks.com/topic/119995-need-help-with-form-logic-and-dynamically-generated-content/#findComment-618128 Share on other sites More sharing options...
digitalgod Posted August 16, 2008 Author Share Posted August 16, 2008 also how can I collect the information for the user created drop down? Should I just use ajax and store it in a temp table until the form is submitted or..? Quote Link to comment https://forums.phpfreaks.com/topic/119995-need-help-with-form-logic-and-dynamically-generated-content/#findComment-618191 Share on other sites More sharing options...
digitalgod Posted August 17, 2008 Author Share Posted August 17, 2008 well got it work by populating an invisible list box and grabbing those values, not exactly the best way but if anyone has a better proposition please let me know! Quote Link to comment https://forums.phpfreaks.com/topic/119995-need-help-with-form-logic-and-dynamically-generated-content/#findComment-618560 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.