473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

text replacement with prototype.js

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
2 3758
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Colin Coghill (SFive) | last post by:
Hi, a year or so back some students of mine and I wrote some software which made use of the rexec module to run untrusted user code relatively safely. (We were creating a prototype of a mobile-code...
8
by: Ernst Murnleitner | last post by:
Hello Readers, I am looking for a replacement of <ctime>. for the functions gmtime mktime One reason is, that these time functions use statically allocated memory but
24
by: Markus Ernst | last post by:
Hi I have a title with a title gif: <h1><img src="mytitle.gif" alt="This is my title"></h1> So this is text-based browser and search-engine friendly and can be easily formatted with a style...
1
by: PC User | last post by:
I found this Rich Text Editor and I've been trying to recreate it in my own application. I've had trouble with the COMCTL.ImageListCtrl and the COMCTL.Toolbar to recreate the toolbar. And I've...
1
by: Dhanak | last post by:
I have around 1000 aspx files that contains standard lines intended for debugging purpose.Now before we put these to production we need to remove these lines from all files. Instead of doing it...
5
by: D | last post by:
hi there , i want to do something fairly simple (well it was simple in PERL) using the replace function of Regex... but i cannot find the docs to help me on it... i want to use a regex to find a...
0
by: rmeshksar | last post by:
Hi, I would like to do text replacement using RegEx and use the following statement: Regex.Replace(input, pattern, replacement, RegexOptions.IgnoreCase) It works fine in all cases except in the...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
0
progdoctor
by: progdoctor | last post by:
I have scripts that can format a HTML input value as a numeric format or money format.. Hope its useful function XFormat(arrayCtl) { this.arrCtl = arrayCtl; if (typeof XFormat._initialized...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.