Web Design Forum: HTML Form - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

HTML Form

#1 User is offline   SteveJo 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 10
  • Joined: 20-October 10
  • Reputation: 0

Posted 17 January 2012 - 10:07 AM

Hi,
I'm trying to create a form with two boxes for an insurance site. I want that in the first box the user will select the type of insurance and in the second box type the zip code. For every insurance type, the surfer will be directed to a different URL.

This is the code that I have, but of course that it doesn't work:
<form name="mainform">
        <tr>
            <td colspan="2">
                <select name="src" id="type">
                    <option value="http://www.mysite.com/results-car.html">Auto</option>
                    <option value="http://www.mysite.com/results-home.html">Home</option>
                    <option value="http://www.mysite.com/results-life.html">Life</option>
                    <option value="http://www.mysite.com/results-health.html">Health</option>
                    <option value="http://www.mysite.com/results-motorcycle.html">Motorcycle</option>
                    <option value="http://www.mysite.com/results-business.html">Business</option>
                </select>
            </td>
            <input type="hidden" name="source" value="google" />
        <tr>
            <td><input type="text" name="zipcode" maxlength="5" id="zip" />
</td>

        </tr>
        <tr>
            <td colspan="2" style="text-align:center;"><input type="submit" id="button" value="Go"/></td>

        </tr>

    </table>
</form>


For example, for auto insurance the URL should be:
http://www.mysite.co...1&source=google


Thanks!!
0

#2 User is offline   Davo 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 17-January 12
  • Reputation: 0

Posted 17 January 2012 - 11:43 AM

I believe that you will need to use JavaScript or some Server side code to accomplish this. The JavaScript option would look something like this:

<head>
<script type="text/javascript">
function getURL(val,zip,source){ 
   base = 'http://www.mysite.com/'; 
   location = base + val + "?zipcode=" + zip + "&source=" + source;
   return false; 
} 
</script> 
</head>

<body>
<form name="mainform" method="post" action="" onsubmit="return getURL(this.src.value, this.zipcode.value, this.source.value)">
            <select name="src" id="type">
                    <option value="results-car.html">Auto</option>
                    <option value="results-home.html">Home</option>
                    <option value="results-life.html">Life</option>
                    <option value="results-health.html">Health</option>
                    <option value="results-motorcycle.html">Motorcycle</option>
                    <option value="results-business.html">Business</option>
            </select>
            <input type="hidden" name="source" value="google" />
            <input type="text" name="zipcode" maxlength="5" id="zip" />
        	<input type="submit" id="button" value="Go"/>
</form>
</body>


I hope this helps.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users