Jump to content

Submit A Form With Select Menu Dropbox Without Submit Button


beginner101

Recommended Posts

I am working on a website with my project mates, in which I need to add a filter dropdown box. When I select one of the option in it, the table being displayed in that webpage will display a different set of data based on the type of data I selected to filter. Also this webpage can only be seen by logging in as a valid user.

 

I am very new to javascript and php programming and after going through several forums, I added the following code as a start to do the filtering, by which the webpage will be able to get the dropdown box option that was selected and display it:

 

 

<script>
function formSubmit()
{
document.getElementById("report_filter").submit();
}
</script>

<form method="POST" id="report_filter" action="" >
<select name="try" onchange="formSubmit();">
<option value="all">All</option>
<option value="Windows">Windows</option>
<option value="Win 2008">Win 2008</option>
<option value="Win 7">Win 7</option>
<option value="Win Vista">Win Vista</option>
<option value ="Linux">Linux</option>
<option value = "Win 7/Linux">Win 7/Linux</option>
</select>
</form>

<?php

if(!(isset($_POST["try"])))
{
  echo "none";
}
else
echo $_POST["try"];

?>

The code above works ok when i run that individually in a separate php page, i.e., it ehoes the option that i select in the drop down box. But not so when I add it to the webpage that I am working on, cause when I select an option in the dropdown box the page goes blank and nothing else happens.

Edited by Zane
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.