Solved

PHP Code Submit Button

Posted on 2011-03-07
2
347 Views
Last Modified: 2012-05-11
In the below code, I need to be able to choose an office from teh drop down box then click the submit button. If I choose "Office A" then click the "Submit button, I need to be redirected to http://mysite/query/officea.php

If I choose "Office B" from the drop down list, I need to be redirected to http://mysite/query/officeb.php

Is this possible?
<body>

	<h1>Please choose an office</h1>
	<br>
		
	<b>Choose an Office: </b><br />   
<select name="office" /> <br />
<option value=""></option> 
<option value="Office A">Office A</option> 
<option value="Office B">Office B</option> 

</select>
<input type="submit" value="Submit" />
</br>
		
</body>

Open in new window

0
Comment
Question by:wantabe2
2 Comments
 
LVL 12

Accepted Solution

by:
enachemc earned 250 total points
ID: 35056817
<body>

      <h1>Please choose an office</h1>
      <br>
            
      <b>Choose an Office: </b><br />  
      <form action="a.html" >
<select name="office" onChange="this.form.action=this.value+'.php'"/> <br />
<option value=""></option>
<option value="OfficeA">Office A</option>
<option value="OfficeB">Office B</option>

</select>
<input type="submit" value="Submit" />
</form>
</br>
            
</body>
0
 
LVL 2

Assisted Solution

by:adeelshahid
adeelshahid earned 250 total points
ID: 35056888
try this.

if (isset($_POST['office'])) {
            switch ($_POST['office'])
            {
                  case 'Office A':
                        header('Location: http://mysite/query/officea.php');
                        die();
                  
                  case 'Office B':
                        header('Location: http://mysite/query/officeb.php');
                        break;
            }
      }
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now