thisisnuts123 Posted November 2, 2007 Share Posted November 2, 2007 hello guys i have read some articles and am trying to figure out how to echo out java script.. i never really understand the consept.. any one can explain better? phpfuntion() { $query = "SELECT `itemnum` , `sitedat` FROM layout WHERE `set` = 'dropbox' "; $result = mysql_query($query); $row = mysql_fetch_row($result); $site[0] = $row[1]; } i wana alert out site[0] how can this be done thanks Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/ Share on other sites More sharing options...
rajivgonsalves Posted November 2, 2007 Share Posted November 2, 2007 here you go funtion() { $query = "SELECT `itemnum` , `sitedat` FROM layout WHERE `set` = 'dropbox' "; $result = mysql_query($query); $row = mysql_fetch_row($result); $site[0] = $row[1]; echo "<script>alert('{$site[0]}');</script>"; } Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383349 Share on other sites More sharing options...
thisisnuts123 Posted November 2, 2007 Author Share Posted November 2, 2007 thank u sir Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383351 Share on other sites More sharing options...
thisisnuts123 Posted November 2, 2007 Author Share Posted November 2, 2007 ok i tried it and it is not working.. it will not send out an alert. is this becuase it's inside a php funtion?? any way to assign it to a java variable and then send an alert out side of php funtion? Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383352 Share on other sites More sharing options...
rajivgonsalves Posted November 2, 2007 Share Posted November 2, 2007 well it depends where you are calling the function more code would be helpful as to where you are calling the function on the page Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383354 Share on other sites More sharing options...
thisisnuts123 Posted November 2, 2007 Author Share Posted November 2, 2007 function update_dropbox($data_array, $col_check) { $i = 0; $o = array(); foreach($data_array AS $set => $items) { foreach($items AS $item) { $item = mysql_escape_string($item); $set = mysql_escape_string($set); $o[$i] = $items[$i]; $query = "SELECT `sitedat` FROM layout WHERE `item` = '$o[0]'"; $result = mysql_query($query); $row = mysql_fetch_row($result); $sitevalue = $row[0]; $i ++; } } echo "<script>alert('{$sitevalue}');</script>"; return $sitevalue; } function sajax_update($data) { $data = parse_data($data); $website = update_dropbox($data, "AND (`set` = 'dropbox')"); return $website; return 'y'; } Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383355 Share on other sites More sharing options...
thisisnuts123 Posted November 2, 2007 Author Share Posted November 2, 2007 and this is the java funtion function onDrop() { var data = DragDrop.serData('g1'); x_sajax_update(data, confirm); } Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383356 Share on other sites More sharing options...
thisisnuts123 Posted November 2, 2007 Author Share Posted November 2, 2007 so when an item is dropeed in to a drop box drop box funtion is called and then it send info to sajax_update which then sends info to update funtion then i waan return the value back to java Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383357 Share on other sites More sharing options...
trq Posted November 2, 2007 Share Posted November 2, 2007 Firstly, you must understand that Java is not Javascript. Secondly, PHP is a server side language which is run on the server and then sends its response to the client. Javascript on the other hand is run on the client. You cannot simply call a Javascript function from PHP and vice versa. Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383358 Share on other sites More sharing options...
thisisnuts123 Posted November 2, 2007 Author Share Posted November 2, 2007 it is using sajax so the information is passed properly to php if i use a debuger program i can see echo "<script>alert('{$site[0]}');</script>"; the variable getting populated. but i can't figure out how to use sajax to now pass the information back to java Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383359 Share on other sites More sharing options...
trq Posted November 2, 2007 Share Posted November 2, 2007 but i can't figure out how to use sajax to now pass the information back to java Um... as I just stated. That would be Javascript NOT Java. They are two completely different and unrelated beasts. Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383361 Share on other sites More sharing options...
thisisnuts123 Posted November 2, 2007 Author Share Posted November 2, 2007 sorry i ment javascript Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383362 Share on other sites More sharing options...
thisisnuts123 Posted November 2, 2007 Author Share Posted November 2, 2007 so.. any one? Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383365 Share on other sites More sharing options...
thisisnuts123 Posted November 2, 2007 Author Share Posted November 2, 2007 just had another look at ajax and i was able to figure it out!!! finaly !!! Quote Link to comment https://forums.phpfreaks.com/topic/75749-solved-php-java-echo-out-java-help/#findComment-383368 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.