Form Submit Button Help!

I crated a form box just like the one on this site. http://www. progresspreferred .com/about_us.php

The form on the left side “Get an Instant quote”

Instead of the “Get a Quote” button i put the regular “Submit Form” button.

<form action=“” method=“post” id=“instant-quote”><table width=“200” border=“0”>
<tr>
<td><span id=“zip-code”>
<label for=“zipCode”></label>
<input type=“text” name=“zipCode” id=“zipCode” tabindex=“1” />
<span class=“textfieldRequiredMsg”><br />
A value is required.</span></span></td>
<td><label for=“procuts”></label>
<select name=“procuts” id=“procuts” tabindex=“2”>
<option value=“Auto” selected=“selected”>Auto</option>
<option value=“Trucks”>Trucks</option>
<option value=“Home”>Home</option>
<option value=“Contractors”>Contractors</option>
<option value=“Business Owners”>Business Owners</option>
</select></td>
</tr>
<tr>
<td><input type=“submit” name=“submit” id=“submit” onclick=“return next()” value=“Continue” tabindex=“3” /></td>
<td> </td>
</tr>
</table>
</form>

NOW I want my visitors to select the insurance product (Auto, Home…) and click on the “submit” button and the submit button takes them to whatever option they chose on the drop down menu. Just the way it work on that website. How can this be done? What do I need to add in the code to make it work? If it is javascript can someone give me the code? I would really appreciate it.

Thank you

To process a form like that, you need some kind of “server side” script, like PHP. You can Google something “PHP contact form” and you’ll find a lot of code examples. (I’ll move this to the PHP forum, anyhow.)

I do not it to process anything. All I want is when they select out it takes them to auto insurance page. Like a link to the submit button so it can take them to the auto page, then another link to the home insurance and the rest… It doesnt have to process anything just move me from location to location… I dont know if this can be done with javascript.

  1. Use JS (requires JS to be enabled)

<select onchange="window.location.href=this.options[this.selectedIndex].value">
<option value="page1.php">Page 1</option>
<option value="page2.php">Page 2</option>
</select>

2, Use PHP to submit the form and then use PHPs header() function.

Where ‘location’ was the name of your variable – which you have to
validate prior to using as in the example below:



// output absolutely nothing to the browser prior to doing this:

if( something is true ){
header('Location: ' . $_POST['location'])
exit();
}


I am not familiar with programing so php is hard for me to understand. I would want to do it with javascript code. have the users make the selection and when they click on the button it redirects them to the location they have selected. Can this be done with javascript? If yes would you please give me the code?

Try the following:
HTML


<select name="page" id="page">
<option value="page1.php">Page 1</option>
<option value="page2.php">Page 2</option>
</select>
<input type="button" name="btncilck" id="btnclick" value="GO" onclick="redirect();" />

JavaScript function redirect() would look like:


function redirect(){
var page = document.getElementById('page');
document.location=page.options[page.selectedIndex].value;
}

The problem with using JavaScript is that anyone who has it off (for whatever reason) won’t be able to move from page to page. That’s why it’s better to let the server handle it.

That is fine. Javascript will do just fine for me.

Then the better Idea is, suppose you are having this form on about_us.php page. so write the following code on top of the about_us.php.

<?php
if(isset($_REQUEST[‘procuts’]) && $_REQUEST[‘procuts’] != NULL){
$page_redirect = $_REQUEST[‘procuts’];
header(“Location: $page_redirect”);
}
?>

Now your form will be like below

<form name=“form” id=“form” action=“<?php $_SERVER[‘PHP_SELF’];?>”>
<select name=“procuts” id=“procuts” tabindex=“2”>
<option value=“auto.php” selected=“selected”>Auto</option>
<option value=“trucks.php”>Trucks</option>
<option value=“home.php”>Home</option>
<option value=“contractors.php”>Contractors</option>
<option value=“business_owners.php”>Business Owners</option>
</select>
<input type=“submit” name=“submit” value=“submit” />
</form>

This will let you to do exactly whatever you want to do.