?
Solved

Dropdown so no submit button is needed...No javascript

Posted on 2008-10-31
8
Medium Priority
?
350 Views
Last Modified: 2013-12-13
I have a dropdown menu and when I select the option I have to hit the submit button. Is there a way without using java scrip that if I select an entry from drop down list, it executes this code
<?php //air code
if (isset('submit')) //this part will be replaced as I will take out the submit button
{
run my code
}

thanks
0
Comment
Question by:syedasimmeesaq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22853367
>>without using java script
No. a dropdown is NOT a submit element. To submit the form you will need a submit button OR scripting to do the submission.
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 22853433
ok how would I do that in javascript so it runs the php code
Thanks
0
 
LVL 6

Expert Comment

by:fourice
ID: 22853442
Perhaps this is what you want?
<script>
	function submitForm(selObj)
	{
		var selIndex = selObj.selectedIndex;
		if(selObj.options[selIndex].value != "")
		{
			document.testForm.submit();
		}
	}
</script>
<form name="testForm" method="post" action="yourfile.php">
	<select name="selectBox" onchange="submitForm(this)">
		<option value="">Choose an option</option>
		<option value="1">1</option>
		<option value="2">2</option>
		<option value="3">3</option>
	</select>
</form>

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 22853471
no I want to run this code when the list is chosen
<?php //air code
if (isset($_POST['submit'])) //this part will be replaced as I will take out the submit button
{
$value = $_POST['dropdownvalue'];
header("location: newpage.php");
exit;
}
?>
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 22853474
<select name="selectBox" onchange="this.form.submit()">
0
 
LVL 82

Expert Comment

by:hielo
ID: 22853489
<?php //air code
if (isset($_POST['selectBox'])) //this part will be replaced as I will take out the submit button
{
$value = $_POST['dropdownvalue'];
header("location: newpage.php");
exit;
}
?>
0
 
LVL 9

Author Closing Comment

by:syedasimmeesaq
ID: 31512164
thanks!
0
 
LVL 82

Expert Comment

by:hielo
ID: 22854677
you are welcome
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

719 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