Re: looking for examples -- link to insert the "content" into a given area

From: Date: Sat, 15 Mar 2025 17:26:53 +0000
Subject: Re: looking for examples -- link to insert the "content" into a given area
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-328654@lists.php.net to get a copy of this message
The short answer is to put in a span tag in the location that you want the content to appear. Give the span tag a UNIQUE id and use the DOM method getElementById( tag id ) then insert the content. In the simplest form as a string. <span id="spanID"></span> // javascript source let target = document.getElementById('spanID'); if(target.hasChildNodes()) { target.childNodes[0].data = 'text to insert'; } else { target.appendChild(document.createTextNode('text to insert')); } The above will insert a string as a child of the span tag <span id="spanID">text to insert</span> But this can get very complicated if you need to insert other elements It is worth mentioning also, that the span tag should be a child of a pre tag. trying to insert text in a p tag will not result in the expected behavior of a p tag, in my experience. The span tag will inherit what ever the CSS rules are assigned to the pre tag. The pre tag is for pre formatted strings as well as most other elements <pre><span id='SPID'></span></pre> This also assumes that you have enough experience with javascript to know how to use this successfully. > > On Mar 15, 2025, at 9:53 AM, bruce <badouglas@gmail.com> wrote: > > Hi. > > Combination php/js issue. > > Trying to find example/explanation on how to insert content froma link into a given area. Just > as a test, did a test webapp, and tested > http://1.2.3.4:/aa.html and the entire page was displayed > from exa,img the page source. . So, I was curious as yo the process if I had a menu item, that > returned content, if I wanted to insert that content into an area on a page. How to accomplish this. > > Searching, haven't found an explanation yet. > > thanks >

« previous php.general (#328654) next »