/    Sign up×
Community /Pin to ProfileBookmark

Change a html string in JS

I hope that this is simple, Im sure it is.

I am trying to change the text of a html output without loading the page.

I know you can do this using a form in this example:

[code=php]<?php printf(“<a href=”javascript: void(0);” onclick=”WriteBack(‘%s’,’%s’, wb_str);”>Apply / Finish</A>”,$_SESSION[“form_name”], $_SESSION[“field_name”]);
?>[/code]
[code=html]

<script language=”JavaScript”>
<!–
function WriteBack(form_name,field_name,corrected_text)
{
opener.document[form_name][field_name].value = corrected_text;

}
–>
</script>[/code]

But to do it this way the output has to be in a form and I don’t want that. I want it to change some normal HTML text. It is also important that the text be changed via a HTML link (a href) like a get method.

[CODE]www.domainname.com/index.php?change=theChangedWord[/CODE]

Thanks for your time.

-ronXX

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@tpircsavajSep 07.2009 — You can write on the page by using <span> or <div>

HTML:

<div id="addName"></div>

JavaScipt:

addName.innerHTML = '<b>John Doe</b><br/>';

OR

addName.innerText = 'John Doe';
Copy linkTweet thisAlerts:
@ronXXauthorSep 08.2009 — thanks that did it.

Here is a good reference: http://www.tizag.com/javascriptT/javascript-innerHTML.php

Thanks,

-ronXX
×

Success!

Help @ronXX 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...