Jump to content

dropdown event


MannyG

Recommended Posts

I have a dropdown menu with an onchange event that works and I would like to run a block of code if an item in the dropdown is selected, i searched but could not find a 'on select' event (if it exists) that gives me a way to know if something has been clicked...thanks

Link to comment
Share on other sites

No I know that in the dropdown I can use an onselect command, but in a if statement where the condition is applied is what I am talking about...so if(onSelect == true) sort of thing, dont know how to do that, here is pseudocode:

 

      //drop down that communicates with mysql

          if(anything_in_dropdown_has_been_selected == true)

            {

              //execute this

          }

 

          else

          {

          //execute this

          }

Link to comment
Share on other sites

No I know that in the dropdown I can use an onselect command, but in a if statement where the condition is applied is what I am talking about...so if(onSelect == true) sort of thing, dont know how to do that, here is pseudocode:

 

      //drop down that communicates with mysql

          if(anything_in_dropdown_has_been_selected == true)

            {

              //execute this

          }

 

          else

          {

          //execute this

          }

 

You should never need to check an event outside of the control the event is for... that's why they are used there. I'm confused at why you are trying to check an onselect outside... And why would you have an else? So if the user is not constantly selecting something then it would do some other code? I'm sure there is a much better way to do what you are wanting to do. Please explain the entire problem you are trying to find a solution for. What are you trying to do?

Link to comment
Share on other sites

No I know that in the dropdown I can use an onselect command, but in a if statement where the condition is applied is what I am talking about...so if(onSelect == true) sort of thing, dont know how to do that, here is pseudocode:

 

      //drop down that communicates with mysql

          if(anything_in_dropdown_has_been_selected == true)

            {

              //execute this

          }

 

          else

          {

          //execute this

          }

 

You should never need to check an event outside of the control the event is for... that's why they are used there. I'm confused at why you are trying to check an onselect outside... And why would you have an else? So if the user is not constantly selecting something then it would do some other code? I'm sure there is a much better way to do what you are wanting to do. Please explain the entire problem you are trying to find a solution for. What are you trying to do?

 

Well I have a table that displays information about products, and you can use the dropdown as a search filter (which sends a specific query to the db and displays the results in the same table), well if nothing is selecte dthen all the data is displayed which is why i have the if-statement...if there is a required search query, run it, else just display all the info

Link to comment
Share on other sites

No I know that in the dropdown I can use an onselect command, but in a if statement where the condition is applied is what I am talking about...so if(onSelect == true) sort of thing, dont know how to do that, here is pseudocode:

 

      //drop down that communicates with mysql

          if(anything_in_dropdown_has_been_selected == true)

            {

              //execute this

          }

 

          else

          {

          //execute this

          }

 

You should never need to check an event outside of the control the event is for... that's why they are used there. I'm confused at why you are trying to check an onselect outside... And why would you have an else? So if the user is not constantly selecting something then it would do some other code? I'm sure there is a much better way to do what you are wanting to do. Please explain the entire problem you are trying to find a solution for. What are you trying to do?

 

Well I have a table that displays information about products, and you can use the dropdown as a search filter (which sends a specific query to the db and displays the results in the same table), well if nothing is selecte dthen all the data is displayed which is why i have the if-statement...if there is a required search query, run it, else just display all the info

 

So you are using ajax to do this then? All you need to do is create a function that holds the ajax code in it for what you need to do. Then in the onselect event you call that function. I assume you know how to get the current value of the drop down box.

Link to comment
Share on other sites

im using php, html, javascript, css only

 

ajax is not a language but rather a way of using javascript to call php. Are you using the xmlHttpRequest? or ajax/post functions?

oh, um no I am not...no idea what ajax is or how to use it..is there anyway to do this without the use of ajax? for example

 

onselect i send a value to some javascript method making a value = 1 and then in php if-statement i check condition if that var is 1 then execute this, else dont...problem is i dont know how to use a javascript variable in php code o_O

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.