The easiest way to do this, is to use the onChange event from the SELECT form element. When the event is fired, you could then call an AJAX function, to populate (by executing a server side script) the DIV tag The below sample assumes the use of jQuery Give your select element an ID select id="myselect"> query 1 query 2 query 3 Widget-content'). Load('runquery.
Php? Id='+this.optionsthis.selectedIndex. Value); }).
The easiest way to do this, is to use the onChange event from the SELECT form element. When the event is fired, you could then call an AJAX function, to populate (by executing a server side script) the DIV tag. The below sample assumes the use of jQuery.
Give your select element an ID query 1 query 2 query 3 Then add a jquery script to populate the DIV tag. $('#myselect'). Change(function() { $('.
Widget-content'). Load('runquery. Php?
Id='+this.optionsthis.selectedIndex. Value); }).
It's clearer to me in this solution how i'd get from the javascript to my 'runquery. Php' file where'd i'd have all my different PHP functions, my question now is how to associate the option value with a specific PHP function. – QuomoPete Dec 12 '10 at 3:48 Well, as the code is sending the value through the PHP script, this would be the identifier of the query you want to return.So, in runquery.
Php, you would read the paramater id and return the query it corresponds to. – Codemwnci Dec 12 '10 at 8:30 I understand that in concept, but I don't know how to do that code-wise in my PHP file (with if(isset...)?) – QuomoPete Dec 12 '10 at 9:40 yes, using $queryId = $_REQUEST'id'; – Codemwnci Dec 12 '10 at 9:43.
This is not possible using PHP, as the action of selecting an item in a dropdown box can only be caught on the client side. You could do this with JavaScript (I recommend using jQuery): $('. Widget-top select').
Change(function() { var payload = {'index': this.optionsthis.selectedIndex. Value}; $. Post('runQuery.
Php', payload, function(response) { //notify user that query ran }); }).
– David Thomas Dec 12 '10 at 0:19 @David, Edited. – Jacob Relkin Dec 12 '10 at 0:23 Thanks Jacob. Yeah, I put it in the title but should have clarified also in the post, i've already got JQuery giving the widgets something extra.
I suppose what I am still curious about it how to connect the value the Javascript returns to a specific function in the runQuery. Php file? – QuomoPete Dec 12 '10 at 3:45.
You'll need to link two parts: The client side and the server side. Generally, you'd want to start with an Ajax-Free solution, as some browsers or users may have JavaScript disabled. The next thing is to create a PHP Page that return a response based on an HTTP (GET or POST) request.To get the request, make use of the array $_GET and $_POST.
So ,as an example, let's say you have two variables: ID and Date, then you'll catch them with $_POST'ID' and $_POST'Date'. Now to send the request, you'll need a FORM (HTML Element). You'll place elements which you wish to submit their status using that FORM.
For example: When the form is submitted (you may need a submit button), the $_POST is populated with the value of the input. Now, you can grab that in the PHP side and return the response.It can be another page or just plain text (if you are planning for AJAX). Ajax just eliminate the need for a Page Refresh.
The process is actually the same. Using jQuery, you can simply imitate the browser to do a Submit request. $.
Post('php_page. Php', data_object, call_back); The call_back function will get the response in its' argument. You catch that and display it (or process it) to the end user.
I really didn't give you a code answer, but I think I gave you a basic idea of how the process work. You may want to read more about HTTP requests and jQuery Ajax functions.
Thanks Omar, even if not a code sample it's good to help me understand the processes going on in the background. – QuomoPete Dec 12 '10 at 3:48.
1) Attach an event listener to the select input to run some JavaScript code when its value changes 2) That JavaScript code makes an AJAX request to a URL on your server containing the chosen query 3) Your PHP script on the server responds with the query results 4) The AJAX request's success handler takes the results and inserts them into the page somewhere You can't simply attach JavaScript to a PHP function, it's a back-and-forth communication between the browser and server you need to build.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.