Jump to content


Photo

External.js has no effect on div echo file.php html


  • Please log in to reply
2 replies to this topic

#1 Heinz Stapff

Heinz Stapff

    Member

  • Member
  • PipPip
  • 80 posts
  • Gender:Male
  • Location:Riberas Del Pilar, Chapala, Jalisco, Mexico
  • Interests:Architecture, AutoCAD,
  • Main OS: Windows 8

Posted 11 August 2011 - 12:47 PM

OK. I had set up an Iframes test site and then changed the frames to divs for UniServer/www/index.html, hopping that creating seperate html files would make it easier to create php files to call onclick of li elements from external.js files that change the div.innerHTML with mysql_query.
The onclick of the query works and the div.innerHTML changes as httpresponce echo file.php, producing the desired html elements in the div The external CSS presents the change perfectly. Unfortunatley the external.js no longer has power over the elements produced by the query. I checked the view source on the page and found that it remained the same and did not reveal the div content change which might mean I can't grab the element values that I need to manipulate the query result html elements.
I realize now that the connection was closed at the end of the query so the elements must be there along with their values even if they don't show up in view source? :rolleyes:

External.js Example part of same js that called mysql_query
function pictureclick( ) {
var f1=document.getElementById('f1');//div changed by mysql_query
var pictures=f1.getElementsByTagName('img');//tags created by mysql_query
var iObj=pictures;
for(var i=0; i<iObj.length; i++) {
	iObj[i].onclick=function( ) { enhance(this);};
	}
};

function enhance(img){
var icell = img.parentNode.parentNode;//accessable in standard html
var pref = icell.getElementsByTagName('input')[2].value;
f1.innerHTML = "<img src='"+pref+"' id='eimage'align='center' style='height:100%; width:auto;'/>   <button id='imgbt' style='position:fixed; top:78%; left:80%; z-index:100;'>Continue Shopping</button>";
alert(pref);//produces ..../file.jpg in standard html not in echo php div content?
}

addEvent(window,'load',function( ){ 
var alreadyrun = false;
if(alreadyrun) {
return;
}
alreadyrun=true;
f1class( );//already acctivated on index.html load
},false); addtocart( );pictureclick( );//addtocart dosen't work on the query result elements either

I'm wondering if this occurs because of the browser change in UniServer and my .js isn't a good cross browser solution though I've taken a lot of care to make it so. :) Any advise Greatly appreciated!

#2 BobS

BobS

    Project Helper

  • Super Moderator
  • PipPipPip
  • 334 posts
  • Location:Santiago Chile
  • Interests:Retiring, computer systems, system design, model railroads....
  • Wiki ID: BobS
  • Main OS: Windows 7

Posted 11 August 2011 - 04:15 PM

And this has to do with PHP.... how? This actually belongs under Programming & Web Design. It's NOT a Uniform Server-related problem, so I'm moving the topic.

Remember, Javascript runs on the client's browser, not on the server.
There is no browser associated with UniServer.

It seems to me that you need to build a chart that shows just where and when the elements are created, transferred, and then acted upon.

Regards,
BobS

#3 Heinz Stapff

Heinz Stapff

    Member

  • Member
  • PipPip
  • 80 posts
  • Gender:Male
  • Location:Riberas Del Pilar, Chapala, Jalisco, Mexico
  • Interests:Architecture, AutoCAD,
  • Main OS: Windows 8

Posted 12 August 2011 - 10:52 AM

BobS Thanks , I wasn't sure that it was a php problem but I'm guessing it might be mybrowser when running the loaded php echo in the div? Is it normal for the view source not to show the updated html? That is a php question. If it isn't then it probably is the browser and options in the browser might be able to correct this? Where did you move the topic and will I be notified of replys? Thanks again, total noob. :rolleyes:

Oh YEAH, I added echo "<link rel type='javascript/text" etc to the .php file to no avail.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users