weekenthe9 Posted March 9, 2009 Share Posted March 9, 2009 [Field Name]: [textbox] [Field Name]: [textbox] [Field Name]: [textbox] .... [Field Name]: [a drop down list] [add button] [current list, not editable] [Field Name]: [textbox] [submit button] There's nothing special about this form about the red line. Here's what I want this line to do: Let's say if the dropdown list has 3 values: Red, Green and Blue. if I select "Red" and click the "Add" button beside it, the form would reload with all the values I previously entered, but the [current list, not editable] is now "Red". Now if I select "Green" and click "Add", the form would reload again, with all the values I previously entered, and the [current list, not editable] should now be "Red, Green". After I'm done with adding stuff from the dropdown list, I will click "Submit" button on the bottom of the page, and all the field I entered, as well as the "Red, Green" list would be sent to a next page which will record these information into database. I'm not sure about how I should code that red line. I know this sounds really confusing, but I can't really find a good way to express it. If you're willing to help but not sure about what I'm asking, please feel free to ask Thanks a lot! Link to comment https://forums.phpfreaks.com/topic/148649-solved-about-a-dynamic-form/ Share on other sites More sharing options...
revraz Posted March 9, 2009 Share Posted March 9, 2009 I wouldn't have the final Submit button, just add them to the DB on ADD. Link to comment https://forums.phpfreaks.com/topic/148649-solved-about-a-dynamic-form/#findComment-780583 Share on other sites More sharing options...
weekenthe9 Posted March 9, 2009 Author Share Posted March 9, 2009 If I don't have the submit button, then on every entry I can only add one item from the dropdown list (e.g. "Red"), what if I want to add several ("Red, Green")? Link to comment https://forums.phpfreaks.com/topic/148649-solved-about-a-dynamic-form/#findComment-780590 Share on other sites More sharing options...
kickstart Posted March 9, 2009 Share Posted March 9, 2009 Hi If you want to do it in php (rather than Javascript) then have a submit button for the full submit and another for just adding a selection from the drop down list. When they just add a selection then you store the selection in a hidden field and put it out in plain text / locked textarea (and also loop through any existing hidden fields of that data outputting it to the plain text / locked textarea as well). Then when they finally press the real submit button you can process the form normally, getting all the previous selections from the hidden fields. That said you could do this with Javascript. An example of dynamically adding hidden fields using Javascript is here. The "Add" links each add a hidden field using a Javascript function (called addElement()). You could do a very similar thing using an onclick event in the select. All the best Keith Link to comment https://forums.phpfreaks.com/topic/148649-solved-about-a-dynamic-form/#findComment-780592 Share on other sites More sharing options...
weekenthe9 Posted March 9, 2009 Author Share Posted March 9, 2009 That's exactly what I wanted! Thank you so much!!! Link to comment https://forums.phpfreaks.com/topic/148649-solved-about-a-dynamic-form/#findComment-780619 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.