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

Prototype: Update with multiple elements and texts

P: n/a
Hi,

I am new to prototype.js and appreciate it a lot.

One simple thing however seems to be impossible? I have a <tdelement
which I want to fill with
- an input field
- text
- another input field

at one step.

i.e.
td = ... (simply the <tdelement)
in1 = new Element('input', ...)
in2 = new Element('input', ...)

Now none of these works: (because in some cases, the element itself is
printed, not its content)

td.update(in1).update(td.innerHTML + 'bla').update(td.innerHTML + in2)

td.update(in1 + 'bla' + in2)

td.update(in1.innerHTML + 'bla' + in2.innerHTML)

....so what *does* it?

(or simply: how do I get the content of a new, not-yet-written,
element?)

Thx!
*************

Marty - it's perfect! You're just not thinking fourth dimensionally!
[Emmett "Doc" Brown]

If you wish to email me, please use newsreply at wuwei minus webservices dot de
Jun 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Marty,

If you are using script.aculo.us, try checking out Builder.node and
Builder.build. Using Builder.node
you can do things like:

var td = Builder.node ('td', {style: '...'},
[Builder.node('input', ...), Builder.node('input',...), 'some plain
text, etc.']);

and Builder.build can even acccept entire xhtml fragments.
On Jun 4, 10:14*am, Daniel Loose <gruenwiesl...@web.dewrote:
Hi,

I am new to prototype.js and appreciate it a lot.

One simple thing however seems to be impossible? I have a <tdelement
which I want to fill with
- an input field
- text
- another input field

at one step.

i.e.
td = ... (simply the <tdelement)
in1 = new Element('input', ...)
in2 = new Element('input', ...)

Now none of these works: (because in some cases, the element itself is
printed, not its content)

td.update(in1).update(td.innerHTML + 'bla').update(td.innerHTML + in2)

td.update(in1 + 'bla' + in2)

td.update(in1.innerHTML + 'bla' + in2.innerHTML)

...so what *does* it?

(or simply: how do I get the content of a new, not-yet-written,
element?)

Thx!

*************

Marty - it's perfect! You're just not thinking fourth dimensionally!
[Emmett "Doc" Brown]

If you wish to email me, please use newsreply at wuwei minus webservices dot de
Jun 27 '08 #2

P: n/a
The Prototype mailing list: http://groups-beta.google.com/group/...rails-spinoffs

//probably the easiest way
$('myTD').insert('Phone number: <input type="text" name="areacode"
maxlength="3" /- <input type="text" name="phonenumber" />');

- JDD
Jun 27 '08 #3

P: n/a
On Jun 4, 7:14 am, Daniel Loose <gruenwiesl...@web.dewrote:
>
One simple thing however seems to be impossible? I have a <tdelement
which I want to fill with
- an input field
- text
- another input field

at one step.
What is wrong with innerHTML?
Thx!
Jun 27 '08 #4

P: n/a
Daniel Loose wrote:
I am new to prototype.js and appreciate it a lot.
I am not and I do not. Exactly because you are new to it you are in no
position to assess its quality. Prototype.js is considered junk around here.
One simple thing however seems to be impossible? I have a <tdelement
which I want to fill with
- an input field
- text
- another input field

at one step.

i.e.
td = ... (simply the <tdelement)
in1 = new Element('input', ...)
in2 = new Element('input', ...)
The declaration for the Element constructor would overwrite the object built
into Gecko-based UAs. At least it would attempt to, we are talking host
objects here.
Now none of these works: (because in some cases, the element itself is
printed, not its content)

td.update(in1).update(td.innerHTML + 'bla').update(td.innerHTML + in2)

td.update(in1 + 'bla' + in2)

td.update(in1.innerHTML + 'bla' + in2.innerHTML)

...so what *does* it?

(or simply: how do I get the content of a new, not-yet-written,
element?)
A new element does not yet have content. `input' elements in particular
always have EMPTY content, or no content at all if you will.
[...]
If you wish to email me, please use newsreply at wuwei minus webservices dot de
There is the Reply-To header for this.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.