westman Posted March 16, 2012 Share Posted March 16, 2012 hi everyone long time no see so let me get to it... i got php outputing a word or 2 and the word is diffrent every time in a link.... <a href="#" onclick="return false" onmousedown="javascript:boxsetup()"><?php echo $word ?></a> now how do i get the php word to post to javascript "onmousedown" to put in a div?i have this so fear... function boxsetup() { alert("Hello World!");} the alert box was a test only Link to comment Share on other sites More sharing options...
dsonesuk Posted March 16, 2012 Share Posted March 16, 2012 <a href="#" onclick="return false" onmousedown="javascript:boxsetup(this.innerHTML)"><?php echo $word ?></a> function boxsetup(theword) { targetelement = document.getElementById("whateveridref");targetelement.innerHTML = theword;} Link to comment Share on other sites More sharing options...
westman Posted March 16, 2012 Author Share Posted March 16, 2012 ok the div i would like to send theword to looks like this on my page <div> <div><div id="title">here is where i need "theword"</div></div></div> how do i change line...targetelement = document.getElementById("whateveridref");in the code? Link to comment Share on other sites More sharing options...
dsonesuk Posted March 16, 2012 Share Posted March 16, 2012 "whateveridre"->"whateveridr"->"whateverid"->"whateveri"->"whatever"->"whatevf"->"whatev"->"whate"->"what"->"wha"->"wh"->"w"->""->"t"->"ti"->"######"->"titl"->"title"-> Link to comment Share on other sites More sharing options...
westman Posted March 17, 2012 Author Share Posted March 17, 2012 am using...targetelement = document.getElementById("#name1->#name2->#title");but "theword" is not going therewhy? Link to comment Share on other sites More sharing options...
dsonesuk Posted March 17, 2012 Share Posted March 17, 2012 look at this "getElementById" 'get element by id", what about this ""whateveridref" "whatever id ref" Now! where is the ID ref/name<div id="title">here is where i need "theword"</div> Please don't reply ' is it "theword" ' "whateveridre"->"whateveridr"->"whateverid"->"whateveri"->"whatever"->"whatevf"->"whatev"->"whate"->"what"->"wha"->"wh"->"w"->""->"t"->"ti"->"######"->"titl"->"title" represents deleting each letter of "whateveridref" then replace, and end up with correct id ref/name, which is.... (the' ######' is what the forum does when it takes the word as being used as Abusive, threatening, defamatory, racist, or obscene. Link to comment Share on other sites More sharing options...
westman Posted March 17, 2012 Author Share Posted March 17, 2012 i got it working with...targetelement = document.getElementById("title"); thank you so much for your time thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.