This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Mozilla XML > October 2005 > XF: Adding select1 items using JS





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author XF: Adding select1 items using JS
Rojek Piotr

2005-10-14, 6:46 pm

how can i add new item to my select1 element using JavaScript??
code example or website would be appreciated
Allan Beaufour

2005-10-17, 6:23 am

Friday 14 October 2005 15:30 skrev Rojek Piotr:
> how can i add new item to my select1 element using JavaScript??
> code example or website would be appreciated


Why does it have to be through JavaScript?

If the <select1> is using an <itemset>, you can use <insert> and <setvalue> to
add to it.

--
Allan Beaufour
Linux Software Engineer

Novell, Inc.
Software for the Open Enterprise
www.novell.com/open
Rojek Piotr

2005-10-17, 6:35 pm

Allan Beaufour wrote:
> Friday 14 October 2005 15:30 skrev Rojek Piotr:
>
>
>
> Why does it have to be through JavaScript?
>
> If the <select1> is using an <itemset>, you can use <insert> and <setvalue> to
> add to it.
>

My situation is:
I have one window that opens second. And this second does some
operations and then it must add some items to select1 which is placed in
the first. That is why I would prefer JS. Maybe I am missing sth because
I am new in XF so please show me the path…
Allan Beaufour

2005-10-18, 6:34 pm

On Monday October 17 2005 18:36, Rojek Piotr wrote:
> Allan Beaufour wrote:
>
> My situation is:
> I have one window that opens second. And this second does some
> operations and then it must add some items to select1 which is placed in
> the first.


Argh. Subforms/multi-window is only on the drawing board in XForms :( We have
<message>, but it only allows for <output> in its content, so that's no help.

> That is why I would prefer JS.


I wish I could give you something better, but this should work though:
var mod = document.getElementById('modelid');
var inst = mod.getInstanceDocument('instanceid');
var parent = inst.getElementById/Tagname/whatever-gets-you-the-nodeset-target;
var newtag = document.createElement("newtag");
newtag.appendChild(document.createTextNode("test value"));
parent.appendChild(newtag);
mod.rebuild();
mod.recalculate();
mod.revalidate();
mod.refresh();
(quicly written, so I might have 100 parse errors, and the likes...)

> Maybe I am missing sth because I am new in XF so please show me the path…


I'll try, that's all I can promise :)

--
Allan Beaufour
Linux Software Engineer

Novell, Inc.
Software for the Open Enterprise
www.novell.com/open

Rojek Piotr

2005-10-24, 6:41 pm

Allan Beaufour wrote:
> On Monday October 17 2005 18:36, Rojek Piotr wrote:
>
>
>
> Argh. Subforms/multi-window is only on the drawing board in XForms :( We have
> <message>, but it only allows for <output> in its content, so that's no help.
>
>
>
>
> I wish I could give you something better, but this should work though:
> var mod = document.getElementById('modelid');
> var inst = mod.getInstanceDocument('instanceid');
> var parent = inst.getElementById/Tagname/whatever-gets-you-the-nodeset-target;
> var newtag = document.createElement("newtag");
> newtag.appendChild(document.createTextNode("test value"));
> parent.appendChild(newtag);
> mod.rebuild();
> mod.recalculate();
> mod.revalidate();
> mod.refresh();
> (quicly written, so I might have 100 parse errors, and the likes...)
>
>
>
>
> I'll try, that's all I can promise :)
>

Thanks it worked and sorry for late answer but i was a bit busy.
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews