| | |
javascript php
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
hey all..
i was wondering if anyone culd help me wid this..
i've a html file with javascript and a php file..
i need to access the db result generated by the php file in my javascript..to dynamically load drop down menu in the html file..
was wondering if i cud use somehin like..
var abc='load.php?array_name='+array_name;
to access the array in php file..
thanks in advance..:-)
i was wondering if anyone culd help me wid this..
i've a html file with javascript and a php file..
i need to access the db result generated by the php file in my javascript..to dynamically load drop down menu in the html file..
was wondering if i cud use somehin like..
var abc='load.php?array_name='+array_name;
to access the array in php file..
thanks in advance..:-)
•
•
Join Date: Sep 2009
Posts: 525
Reputation:
Solved Threads: 61
0
#3 30 Days Ago
on click of the select element run the php file through ajax which will fetch the values from the db and will populate the select element.
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
0
#4 29 Days Ago
•
•
•
•
on click of the select element run the php file through ajax which will fetch the values from the db and will populate the select element.
do you mean something like..
<select name=blabla onclick=function_name_inajax();>
thanks in adavance..
do not forget to send sample code..
•
•
Join Date: Sep 2009
Posts: 525
Reputation:
Solved Threads: 61
0
#5 25 Days Ago
It will be good if you try to code yourself, we are always there to help you out if you get stuck up somewhere in the code, to start with, here is the ajax functions you can use -
you can call the httpRespObj(url) on focus of the select element(whatever way you like it).
"url" is your php script (i called it fetch.php) which fetches the data from the db.
<select onFocus="return httpRespObj('fetch.php?id=<?=$id?>');">
If you dont need to pass any id to the request, you can safely omit that part
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function httpRespObj(url) { try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.open("GET",url,false); xmlHttp.onreadystatechange=responseBack; xmlHttp.send(null); } function responseBack() { if(xmlHttp.readyState==4) { //put the response to the html select element document.getElementById("selElement").value = xmlHttp.responseText; } else { document.getElementById("selElement").value=""; } }
"url" is your php script (i called it fetch.php) which fetches the data from the db.
<select onFocus="return httpRespObj('fetch.php?id=<?=$id?>');">
If you dont need to pass any id to the request, you can safely omit that part
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
![]() |
Similar Threads
- Is there a way to detect Javascript using PHP (PHP)
- External JavaScript and PHP Problem (PHP)
- how to access accessing PHP variable in JavaScript (PHP)
- JavaScript/PHP Sessions (JavaScript / DHTML / AJAX)
- Help -regarding Loading Labels In Html From Xml Using Javascript Or Php (JavaScript / DHTML / AJAX)
- how to extract data from javascript into php (PHP)
- merge javascript with php... (PHP)
- PHP with Javascript Parsing (PHP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Dynamic Ajax Content and Jquery
- Next Thread: New web design need help connecting sql database to display content in a form mask
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp animate array automatically beta box bug calendar cart checkbox class codes column createrange() css cursor date debugger decimal design dom download dropdown editor element embed enter error explorer firefox focus frameworks getselection google gwt hint html htmlform ie7 ie8 iframe images index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math menu microsoft mimic mp4 object onmouseover onreadystatechange parent paypal php player position post problem programming progressbar prototype redirect regex runtime safari scale scriptlets search select shopping size sql text textarea toggle w3c web website window windowofwords windowsxp wysiwyg \n





