Tuesday 15 February 2011

php - I have one select list, which should send data with a few forms -


I have such a site: (set of form)

  & lt; Select ID = "Group_dropdown" name = "selection input" & gt; & Lt; Option value = 0> All & lt; / Options & gt; & Lt; Option value = 1> 1 option & lt; / Options & gt; & Lt; Option value = 2> 2 options & lt; / Options & gt; & Lt; / Select & gt; & Lt; Form method = "post" class = "form-inline" id = "form11" & gt; & Lt; Input type = "text" name = "1forminput" placeholder = "0" & ​​gt; & Lt; / Label & gt; & Lt; Button type = "submit" class = "btn btn-success ml40" & gt; Save & lt; / Button & gt; & Lt; / Form & gt; & Lt; Form method = "post" class = "form-inline" id = "form22" & gt; & Lt; Input type = "text" name = "forminput" placeholder = "0" & ​​gt; & Lt; / Labels & gt; & Lt; Button type = "submit" class = "btn btn-success ml40" & gt; Save & lt; / Button & gt; & Lt; / Form & gt;   

I want to send data from this selection (which is "mutual" for both of these forms) when any of these forms are sent (such as an additional field withind sender form ). Is this a simple solution for that?

Add a hidden information and valid markup with the initial label tag etc.

  & lt; Select ID = "group_dropdown" name = "selection input" & gt; & Lt; Option value = "0" & ​​gt; All & lt; / Options & gt; & Lt; Option value = "1" & gt; 1 option & lt; / Options & gt; & Lt; Option value = "2" & gt; 2 options & lt; / Options & gt; & Lt; / Select & gt; & Lt; Form method = "post" class = "form-inline" id = "form11" & gt; & Lt; Label & gt; & Lt; Input type = "text" name = "1forminput" placeholder = "0" /> & Lt; Input type = "hidden" name = "selection_name" /> & Lt; / Labels & gt; & Lt; Button type = "submit" class = "btn btn-success ml40" & gt; Save & lt; / Button & gt; & Lt; / Form & gt; & Lt; Form method = "post" class = "form-inline" id = "form22" & gt; & Lt; Label & gt; & Lt; Input type = "text" name = "forminput" placeholder = "0" /> & Lt; Input type = "hidden" name = "selection_name" /> & Lt; / Labels & gt; & Lt; Button type = "submit" class = "btn btn-success ml40" & gt; Save & lt; / Button & gt; & Lt; / Form & gt;   

Then fill out the selected input when the value of the selection changes:

  $ ('# group_dropdown'). ('Change', function () {$ ('[name = "select_value"]'). Val (this.value);}) Trigger ('change');   

and selection values ​​will be sent with both forms when they are submitted, and will be accessed:

  $ _ POST ['select_value' ];    

No comments:

Post a Comment