I posted before about .innerHTML problems with divs.. Now i've found the problem again.. I'm using XMLHttpRequest to add form to a div in a document.. The form is dynamic (asp) I need a JS script in the form that creates a link form the data in the fields to submit as a query string.. Now the function work fine on the form page alone but not when XMLHttpRequest into a div.. I've discovered the function need to be in the main page to work.. But I need to build the function in the asp form page due to the fact is dynamic? Any way to pass from a XMLHttpRequest page to the main page ? Or any other work arounds ?
Maybe this helps you: call to a javascript function (F1) defined on your main, but passing parameters obtained from your div (filled with results from XMLHttpRequest). Or you can use only one string parameter filled with your "javascript code" and executed with "eval" inside your F1 function.
Life is much better if you could provide the code you are having trouble. We can't guess what is happening in the code.
Cool.. I have found one way by calling a js function on the main page from the imported page but the asp on the imported page build the JS function due to it being dynamic.. Here some code hope its helps.. Main import standard function on the main page: function ahah(url, target) { document.getElementById(target).innerHTML = ' Fetching data...'; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if (req != undefined) { req.onreadystatechange = function() {ahahDone(url, target);}; req.open("GET", url, true); req.send(""); } } function ahahDone(url, target) { if (req.readyState == 4) { // only if req is "loaded" if (req.status == 200) { // only if "OK" document.getElementById(target).innerHTML = req.responseText; } else { document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText; } } } function load(name, div) { ahah(name,div); return false; } Code (markup): Sub page code that creates the click link query string.. iCounter is the number of fields.. This works perfectly on on the page it's self.. function showlink(){ <% dim i for i=0 to iCounter %> str<%=i%> = "&date_<%=i%>="+window.document.form2.date_<%=i%>.value+"&order_<%=i%>="+window.document.form2.order_<%=i%>.value; <% next i=0 %> document.getElementById("area2").innerHTML = "<a href=# onClick=sendtoserver('<%="POListX2.asp?OrderNo="&trim(sOrderNo)&"&items="&iCounter+1%>"<% for i=0 to iCounter %>+str<%=i%><%next%>+"') >Update</a>"; } PHP: The "sendtoserver" function updates the DB which works fine... This part of the above is the probelm.. document.getElementById("area2").innerHTML = "<a href=# onClick=sendtoserver('<%="POListX2.asp?OrderNo="&trim(sOrderNo)&"&items="&iCounter+1%>"<% for i=0 to iCounter %>+str<%=i%><%next%>+"') >Update</a>"; Code (markup): The div "area2" fails due to the fact its being called within a .innerhtml call with the top function .. Thanks for the help..