Solved

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

Posted on 2008-10-31
8
342 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 82

Accepted Solution

by:
hielo earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

863 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

25 Experts available now in Live!

Get 1:1 Help Now