Jump to content

Need Data to change on page when dropdown selection is made


CincoPistolero

Recommended Posts

I have a page that makes a list based on all open tickets. I'd like to have a dropdown on that page that users can make a selection and then the page refreshes with either just their open tickets, are all their closed tickets or both.

 

I can figure out all the different db select statements to display the different data, but I'm confused on how to run the dropdown box. I'd like to stick with PHP and not do any javascript.

 

Can anyone point me towards a tutorial or make suggestion, like: use switch statements or if/else.

 

Can I do something like this in PHP

<form action="" method="post" name="pageView" >

 

<select name="viewList" onchange="OnChange(this.form.viewList);">

 

and have this call a function

 

Signed,

Confused

you'd need to use javascript.. but include a button somewhere under or to th eside of the button incase a user has disabled JavaScript..

 

but you'd do something like this:

 

<script type="text/javascript">
  function _switch(obj) {
    //either submit the form (which you could do from onChange .submit()
    // or set the new url manually..
    top.location = "http://new.url.com/?whatever="+obj.value;
  }
</script>
<select name="whatever" onChange="_switch(this)">
  <option value="1">Whatever</option>
</select>

Based on which selection is made, a new call to the database will need to be made. Can that be done from within a javascript switch statement.

 

does PHP have an onchange or should I call a class file each time and the db call made is based on the value of the dropdown? Can the page then update itself?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.