Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only. Moving forward, myibi is our community platform to learn, share, and collaborate. We have the same Focal Point forum categories in myibi, so you can continue to have all new conversations there. If you need access to myibi, contact us at myibi@ibi.com and provide your corporate email address, company, and name.


Connect to myibi
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] assign dynamic value to drop down list

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] assign dynamic value to drop down list
 Login/Join
 
Gold member
posted
Hi all,

I am trying to load the value from one drop down list to another.

I am able to fetch the value from the drop down 3 and couldnt assign to drop down 1. I used the below code.

document.getElementById('combobox1').options[i]value = document.getElementById('combobox3').options[i].value;

I have put the above code in 'for' loop and the index value is substituted for 'i'.

Any suggestions would be greatly helpful.

Thanks,
Ramya

This message has been edited. Last edited by: Kerry,


WebFocus 7702
HTML
 
Posts: 73 | Registered: January 02, 2012Report This Post
Virtuoso
posted Hide Post
Is that an actual portion of your code? if so, you're missing a dot between options[i] and the "value" property when assigning to combobox1.

It should look like this:

document.getElementById('combobox1').options[i].value = document.getElementById('combobox3').options[i].value;



Now, to avoid querying the DOM unnecessarily you may:

var box1 = document.getElementById('comboxbox1');
var box3 = document.getElementById('comboxbox3');

for (i = 0; i < box3.options.length; i++) {
   box1.options[i].value = box3.options[i].value;
}



I'm sure there is a more efficient way of doing this but this is not a JavaScript forum which is why I dared to give the code above without much embarrassment Wink



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Member
posted Hide Post
Try this -- I don't think njsden's code will work.
 function onInitialUpdate()
{


var box1 = document.getElementById("combobox1");
var box2 = document.getElementById("combobox2");

for (i = 0; i < box1.options.length; i++) {
   var opt = document.createElement("option");
   box2.options.add(opt);
   opt.text = box1.options[i].text;
   opt.value = box1.options[i].value;	
}

}
 


WebFocus 7.1.3
Developer studio 7.6.4
Windows
Excel, HTML and PDF
 
Posts: 14 | Registered: March 31, 2009Report This Post
Gold member
posted Hide Post
Hi Aneela,

That really helped us. It worked perfectly.

Thanks a lot,

Ramya


WebFocus 7702
HTML
 
Posts: 73 | Registered: January 02, 2012Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] assign dynamic value to drop down list

Copyright © 1996-2020 Information Builders