troubleshooting Question

How can I keep user input in a drop down select field in an html form?

Avatar of dmalovich
dmalovich asked on
PHP
21 Comments1 Solution234 ViewsLast Modified:
I have this form.  How can I keep the users data after the form is submitted?
<form name="duty" action="index.php" method="POST">              
        <select name="province"  onchange=""> 
		     <option value="">Select Province</option>
			<option value="Alberta">Alberta</option>
            <option value="British Columbia">British Columbia</option>
            <option value="Manitoba">Manitoba</option>
            <option value="New Brunswick">New Brunswick</option>
            <option value="Nfld.">Nfld.</option>
            <option value="Nova Scotia">Nova Scotia</option>
            <option value="Ontario">Ontario</option>    
            <option value="P.E.I.">P.E.I.</option>
            <option value="Quebec">Quebec</option>
            <option value="Saskatchewan">Saskatchewan</option>
            <option value="N.W.T.">N.W.T.</option>
            <option value="Nunavut">Nunavut</option>
            <option value="Yukon">Yukon</option>
        </select><br /><br />
                                          
        <select name="alcohol_type" size="1"
        onchange="setOptions(document.duty.alcohol_type.options[document.duty.alcohol_type.selectedIndex].value);">
            <option value="0">Type Of Alcohol</option>
            <option value="1">Spirits</option>
            <option value="2">Spirit Coolers</option>
            <option value="3">Wine</option>
            <option value="4">Wine Coolers</option>
            <option value="5">Sparkling Wine</option>
            <option value="6">Cider</option>
            <option value="7">Beer</option>    
        </select><br /><br />
        
        Cost $CDN:<br /><input size="10" type="text" name="cost" value="<?php echo isset($_POST['cost']) ? $_POST['cost'] : '' ?>" /><br /><br />
                
        <select id="typeSpirits" name="quantity" size="1">
            <option value=" " selected="selected">Select Quantity</option>
        </select><br /><br />
        
        Alcohol %:<br /> <input size="10" type="text" name="percentage" value="<?php echo isset($_POST['percentage']) ? $_POST['percentage'] : '' ?>" /><br /><br />
        
        <select name="spirits_type">
            <option value="">Type of Spirits</option>
            <option value="Whisky">Whisky</option>
            <option value="Rum">Rum</option>
            <option value="Vodka">Vodka</option>
            <option value="Tequila">Tequila</option>
            <option value="Gin">Gin</option>
            <option value="Liqueurs">Liqueurs</option>
            <option value="Brandy/Cognac">Brandy/Cognac</option>
            <option value="Other">Other</option>
        </select><br /><br />
                
        <select name="outside_country">
            <option value="">Made Outside Canada, USA, Mexico?</option>
            <option value="No">No</option>
            <option value="Yes">Yes</option>
        </select><br /><br />
 
<select id="bottled_in" name="bottled_in">
                  <option value="">Bottled In?</option>
                  <option value="Canada">Canada</option>
                  <option value="United States">United States</option>
                  <option value="Mexico">Mexico</option>
                  <option value="Australia">Australia</option>
                  <option value="New Zealand">New Zealand</option>
                  <option value="South Africa">South Africa</option>
                  <option value="France">France</option>
                  <option value="Other">Other</option>
            </select><br /><br />
    
        <input id="submitbutton" type="submit" name="submit1" value="Calculate Duty" tabindex="3" />     
                            
    </form>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 21 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros