trojanFisch
Programmer
i have a php file that generates some javascript for a page. the my problem is is that things change on the page that the javascript cant account for.
now that i've described the general problem, i'll go into the specifics of my issue:
on the page there is a table, and when one of the cells is right clicked, a dropdown menu is displayed in that cell. when the user selects one of the options in the cell, the dropdown goes away and the option that was selected is displayed in the cell.
when one of the options is selected in one of the rows, that option need to be a different color in the dropdown list.
my problem lies with the options changing color.
i recently inherited this program, and the way it used to run was that the entire page was reloaded when a change was made, but i wos hired to implement ajax methods to not have the pages refresh but rather dynamically reload.
so when the page refreshes the new javascript is reflected, but i cannot seem to dynamically replace the current javascript with the javascript that is generated with php.
this is the code that calls the php code that generates the javascript:
function updateJS(){
http_request_update_js = getHttpRequest();
var url="Javascript2.phtml";
url=url+"?sid="+Math.random();
http_request_update_js.onreadystatechange=stateChangedUpdateJS;
http_request_update_js.open('GET',url,true);
http_request_update_js.send(null);
return;
}
function stateChangedUpdateJS() {
if (http_request_update_js.readyState==4 || http_request_update_js.readyState=="complete"){
if (http_request_update_js.status == 200) {
//alert("No problem with the request");
JS.innerHTML = http_request_update_js.responseText;
http_request_update_js = false;
} else {
alert('There was a problem with the stateChangedUpdateJS request.');
}
return;
}
}
and this is how i thought i could put the new javascript into my page, but appearently this method doesnt work with javascript.
<head>
<div id="JS">
<? include("Javascript.phtml");?>
</div>
</head>
if anyone could help with a solution or throw me a suggestion that'd be great
now that i've described the general problem, i'll go into the specifics of my issue:
on the page there is a table, and when one of the cells is right clicked, a dropdown menu is displayed in that cell. when the user selects one of the options in the cell, the dropdown goes away and the option that was selected is displayed in the cell.
when one of the options is selected in one of the rows, that option need to be a different color in the dropdown list.
my problem lies with the options changing color.
i recently inherited this program, and the way it used to run was that the entire page was reloaded when a change was made, but i wos hired to implement ajax methods to not have the pages refresh but rather dynamically reload.
so when the page refreshes the new javascript is reflected, but i cannot seem to dynamically replace the current javascript with the javascript that is generated with php.
this is the code that calls the php code that generates the javascript:
function updateJS(){
http_request_update_js = getHttpRequest();
var url="Javascript2.phtml";
url=url+"?sid="+Math.random();
http_request_update_js.onreadystatechange=stateChangedUpdateJS;
http_request_update_js.open('GET',url,true);
http_request_update_js.send(null);
return;
}
function stateChangedUpdateJS() {
if (http_request_update_js.readyState==4 || http_request_update_js.readyState=="complete"){
if (http_request_update_js.status == 200) {
//alert("No problem with the request");
JS.innerHTML = http_request_update_js.responseText;
http_request_update_js = false;
} else {
alert('There was a problem with the stateChangedUpdateJS request.');
}
return;
}
}
and this is how i thought i could put the new javascript into my page, but appearently this method doesnt work with javascript.
<head>
<div id="JS">
<? include("Javascript.phtml");?>
</div>
</head>
if anyone could help with a solution or throw me a suggestion that'd be great