Jump to content

php and javascript


Guest

Recommended Posts

sorry to hijack but I am looking for a way to do the oposite if anyone knows that aswell

I need to figure out how to pass a javascript variable to a NEW php page , so that I can echo the javascript variable results to a php variable and then insert it into a database




Link to comment
https://forums.phpfreaks.com/topic/28318-php-and-javascript/#findComment-129500
Share on other sites

Yeah you can get JavaScript to run a php file, not sure how on a seperate server.  I'm not too hot with JS but here's a snippet I fished out of an external .js file I use to get results from a database and use them in a drop down menu.
[code]
<?php

var ajax_list_externalFile = "../lib/php/ajax-list-companies.php";

        ajax_optionDiv.innerHTML = '';
var ajaxIndex = ajax_list_objects.length;
ajax_list_objects[ajaxIndex] = new sack();
var url = ajax_list_externalFile + '?' + paramToExternalFile + '=1&letters=' + inputObj.value.replace(" ","+");
ajax_list_objects[ajaxIndex].requestFile = url; // Specifying which file to get
ajax_list_objects[ajaxIndex].onCompletion = function(){ ajax_option_list_showContent(ajaxIndex,inputObj,paramToExternalFile); }; // Specify function that will be executed after file has been found
ajax_list_objects[ajaxIndex].runAJAX(); // Execute AJAX function
?>
[/code]

Don't know If you can make more sense of that but I hope it helps ;)
Link to comment
https://forums.phpfreaks.com/topic/28318-php-and-javascript/#findComment-129588
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.