/    Sign up×
Community /Pin to ProfileBookmark

table cell content – how to change?

Hi,
Wondering if anybody can help with some coding advice here….
I have in a PHP page code in the following form:

<tr>
<td>
<div class=”textcontent”>
<? include(“content/info01.txt”); ?>
</div>
</td>
</tr>

The “info01.txt” file contains html tags including image tags. I want to be able to include links within this text file too, so that when clicked, a different set of content “info02.txt” will appear in place of the original included content. I don’t want to load an entire new page though (as this is a client-changeable section and I want to limit the client to changing included text files content only, not the whole html document), so I just want to make some kind of link which will replace the section within the <div> tags above so I can maintain the css of that included content.

Is there some easy way of doing this? I thought perhaps I could give the <td> an identifier (say “includearea”) and within the included text file use an onClick statement to load the new content, something like
onClick=”document.includearea.something=newcontent”
but can’t work out how to code this…. what is the “something” and how could I define “newcontent”?

I’m stuck. Any suggestions would be most appreciated.

Thanks in advance…

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@FangDec 18.2005 — iframe or [URL=http://jibbering.com/2002/4/httprequest.html]XML HTTP Request object[/URL]

Don't forget a solution is also required for users with JavaScript disabled.
Copy linkTweet thisAlerts:
@sherpaauthorDec 18.2005 — Thanks for the suggestion.

The iframe option would be great in terms of referencing, linking etc. But the problem is that the class definition involves floating the text over a transparent box through which the background image of the page is visible. By using iframe, the iframe simply cuts a hole in the page and displays independently. I can't simply put the class declaration in the iframe source either, because then there is a mismatch between the background image of the original page and the image inside the iframe.

This is why I simply want to replace the included text - trying other means becomes a bit of a nightmare.

XML HTTP request object - your linked page is beyond my comprehension! Could you perhaps give a simple example of how this might help me - I have no idea where to begin...

Thanks
Copy linkTweet thisAlerts:
@FangDec 18.2005 — XML HTTP request object - that was a simple example.

Back to the iframe. Place a hidden iframe on the page, load the new text into the frame then copy that to the target element.
Copy linkTweet thisAlerts:
@sherpaauthorDec 18.2005 — Hidden iframe - excellent idea Fang - thanks - I'll try this one....
Copy linkTweet thisAlerts:
@sherpaauthorDec 18.2005 — Place a hidden iframe on the page, load the new text into the frame then copy that to the target element.[/QUOTE]
Stuck again - this leads me back to the same question as my original post!

I now have the text in the hidden iframe "theframe", but how do I copy it to the target element (i.e. the <td> - id="thecell")? I'm trying:

document.thecell.src = theframe.src

and document.thecell= theframe.src

and document.thecell=theframe

but none of these is right. I must be missing something obvious....
Copy linkTweet thisAlerts:
@FangDec 18.2005 — document.getElementById('thecell').innerHTML=window.frames['hiddenIframeName'].document.body.innerHTML;
Copy linkTweet thisAlerts:
@sherpaauthorDec 18.2005 — Ah, the innerHTML property - never heard of this one before - it's brilliant.

Thanks so much, Fang - you've turned a potential nightmare into a piece of cake.
×

Success!

Help @sherpa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...