Wednesday, March 14, 2007

Tech post - Javascript : Options List

One of the common problems when dealing with 2 different windows in Javascript is updating new values to be displayed on the parent window.

Parent window is the root window which user click and produce a popup window, called "child".

My solution for updating lists concurrently in 2 different windows via selection from a popup window can be seen from the images below.

Consider that your "select" object name is "objectName" and name of the parent form is parentForm. Sample HTML with one existing option in the list:
<select id="parentForm:objectName" name="parentForm:objectName" multiple="multiple" size="10"><option value="123*">[1]-123*</option></select>

To add a new option into the list from a popup window to the parentForm, any of the solutions can be used:

Solution1:
Solution2:

ps: both solutions are to cater for IE. For Firefox browser, try using "try{} and catch{}".

1 comment:

ShadowFox said...

cool verification word i got.

bjaya

Anyway, your assignment seems very interesting and challenging.

It sounds quite fun.

Still don't understand the purpose for updating the list values using a pop up.

If you think javascript is gay, wait till you try vbscript.

If javascript is gay, then vbscript is bapok.