javascript - how to submit a value and select that option in next page? -


I do not know too much HTML, so when I click on a button, value life When I click on this button, it should go to the next page (which is a contact form) and select that option from the drop down list.

The first page

  & lt; Input type = "submit" name = "type" value = "stroke" & gt;  

The second page

  & lt; Select class = "form-control" id = "type" name = "type" & gt; & Lt; Option value = "life" & gt; Life insurance & lt; / Options & gt; & Lt; Option value = "trauma" & gt; Trauma Insurance & lt; / Option & gt; & Lt; Option value = "tpd" & gt; Total & amp; Amp; Permanent Disability Insurance & lt; / Options & gt; & Lt; Option value = "income" & gt; Income Security Insurance & lt; / Options & gt; & Lt; Option value = "redundancy" & gt; Redundancy insurance & lt; / Options & gt; & Lt; Option value = "personal" & gt; Private Medical Insurance & lt; / Options & gt; & Lt; Option value = "mortgage" & gt; Mortgage protection insurance & lt; / Options & gt; & Lt; Option value = "health" & gt; Health insurance & lt; / Options & gt; & Lt; / Select & gt;     

Post text "itemprop =" text ">

Of course there are several ways to deal with this On the first page (call it first_page.php ), set a form. The action = "" attribute should be indicated in the second page (this is the second_page. Php ), then the second page may be able to get the value obtained from those first values ​​and process it. In this example, used $ _

first_page.php (simple form)

 . 
Trama

This is just a simple form method = "GET" , action = "second_page.php"

second_page.php < / Code>

  // If a button variable is $ selected = '; If (isset ($ _GET ['button'])) {$ select = $ _GET ['button']; 'Life Insurance', 'Fault' = & gt; 'Trauma Insurance', 'TPD' = & gt; 'Total' & amp; // Value Array ('life' = & gt; meet // default selection value $ select_values ​​= 'permanent disability insurance', 'redundancy' => 'income protection insurance', 'private' = & gt; 'Private medical insurance', 'mortgage' => 'mortgage protection insurance', 'health' => 'health insurance',); ? & Gt; Select the class = "form control" id = "type" name = "type" & gt; // loop it, in travel, if selected value in first page matches, // then that feature is selected & lt; & Lt ;? Php foreach ($ select_values ​​$ value = & gt; as $ name):? & Gt; & Lt; Option value = "& lt ;? php echo $ value ;? & gt;" & Lt ;? Php echo ($ selected == $ value)? 'Selected' : '' ; ? & Gt; & Gt; & Lt ;? Php echo $ name; ? & Gt; & Lt; / Options & gt; & Lt ;? Php endforeach; ? & Gt; & Lt; / Select & gt;  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -