By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,309 Members | 1,234 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,309 IT Pros & Developers. It's quick & easy.

text replacement with prototype.js

P: n/a
Hello,
I am using the prototype.js http://prototype.conio.net library for a
project and so wanted to use the Insertion function to replace text
within a table. I want to simply replace what is within a <td> with the
updated
text, but I can only seem to add to whats there. for example

<td id="textToReplace">Some text to replace</td>
becomes
<td id="textToReplace">Some text to replace text gets added on</td>

granted I am using the Insertion['Bottom'] class, but there is nothing to
replace the text such as Insertion['Replace'] as far as i can tell

The behavior i am after is what the Ajax.Updater does, so

<td id="textToReplace">Some text to replace</td>
becomes
<td id="textToReplace">New Text here</td>

but just the Ajax.Updater is not appropriate in this situation.

Here are my examples

http://www.chucklarge.mine.nu/test/p...pdateTotal.htm

I am trying create a real time calculator to generate a total cost of a
product
depending on the number of items. I want to be able to keep entering
a new value and have it display the new subtotal, shipping, and total
without
adding on to the previous calculations.

below that is the Ajax.Updater that exhibits the behavior i want.
So I guess my question is how to go about this. I am really new to
js and found this library to do most of what i need, but now need
to start modifying it and don't have any idea where to start.

Thanks,
Chuck

Aug 27 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
chuck wrote:
I am using the prototype.js http://prototype.conio.net library for a
project and so wanted to use the Insertion function to replace text
within a table. I want to simply replace what is within a <td> with the
updated
text, but I can only seem to add to whats there. for example

<td id="textToReplace">Some text to replace</td>
becomes
<td id="textToReplace">Some text to replace text gets added on</td>

granted I am using the Insertion['Bottom'] class, but there is nothing to
replace the text such as Insertion['Replace'] as far as i can tell
I have never used prototype.js nor understand what Insertion['Bottom']
is. However what you want to do can be done by normal DOM methods.

var parent = document.getElementById("textToReplace");
var newChild = document.createTextNode("New Text here");
parent.replaceChild(newChild, parent.firstChild);
So I guess my question is how to go about this. I am really new to
js and found this library to do most of what i need, but now need
to start modifying it and don't have any idea where to start.


I think it might be wise to learn about DOM.
http://www.w3.org/TR/2000/REC-DOM-Le...1113/core.html

So what is this prototype library? How would it benefit me?

Robert.
Aug 29 '05 #2

P: n/a
Robert wrote:
So what is this prototype library? How would it benefit me?


It can give you a higher level of abstraction, if you want that. How it
can benefit you? Judge for yourself:

http://prototype.conio.net/
http://www.sergiopereira.com/articles/prototype.js.html

Michael

--
Michael Schuerig Those people who smile a lot
mailto:mi*****@schuerig.de Watch the eyes
http://www.schuerig.de/michael/ --Ani DiFranco, Outta Me, Onto You

Aug 29 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.