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 Quote Link to comment Share on other sites More sharing options...
themistral Posted April 19, 2010 Share Posted April 19, 2010 [user deleted] Quote Link to comment 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 Quote Link to comment 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 } Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.