MannyG Posted April 19, 2010 Share Posted April 19, 2010 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 https://forums.phpfreaks.com/topic/199004-dropdown-event/ Share on other sites More sharing options...
themistral Posted April 19, 2010 Share Posted April 19, 2010 [user deleted] Link to comment https://forums.phpfreaks.com/topic/199004-dropdown-event/#findComment-1044569 Share on other sites More sharing options...
teamatomic Posted April 19, 2010 Share Posted April 19, 2010 Just how hard did you look? onSelect. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/199004-dropdown-event/#findComment-1044570 Share on other sites More sharing options...
MannyG Posted April 19, 2010 Author Share Posted April 19, 2010 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 https://forums.phpfreaks.com/topic/199004-dropdown-event/#findComment-1044571 Share on other sites More sharing options...
teamatomic Posted April 19, 2010 Share Posted April 19, 2010 You check it the same way you would for any other form data. if the name is "drop", $_POST['drop'] is a var, if the name is drop[] then $_POST['drop'] is an array. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/199004-dropdown-event/#findComment-1044576 Share on other sites More sharing options...
MannyG Posted April 19, 2010 Author Share Posted April 19, 2010 I don't understand when you say name is drop, do u mean if the name of the form is drop, then i use the post which is a var..but how do i use that in a if statement? Link to comment https://forums.phpfreaks.com/topic/199004-dropdown-event/#findComment-1044578 Share on other sites More sharing options...
aeroswat Posted April 19, 2010 Share Posted April 19, 2010 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 https://forums.phpfreaks.com/topic/199004-dropdown-event/#findComment-1044580 Share on other sites More sharing options...
MannyG Posted April 19, 2010 Author Share Posted April 19, 2010 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 https://forums.phpfreaks.com/topic/199004-dropdown-event/#findComment-1044583 Share on other sites More sharing options...
aeroswat Posted April 19, 2010 Share Posted April 19, 2010 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 https://forums.phpfreaks.com/topic/199004-dropdown-event/#findComment-1044593 Share on other sites More sharing options...
MannyG Posted April 19, 2010 Author Share Posted April 19, 2010 im using php, html, javascript, css only Link to comment https://forums.phpfreaks.com/topic/199004-dropdown-event/#findComment-1044596 Share on other sites More sharing options...
aeroswat Posted April 19, 2010 Share Posted April 19, 2010 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? Link to comment https://forums.phpfreaks.com/topic/199004-dropdown-event/#findComment-1044627 Share on other sites More sharing options...
MannyG Posted April 19, 2010 Author Share Posted April 19, 2010 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 https://forums.phpfreaks.com/topic/199004-dropdown-event/#findComment-1044700 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.