473,508 Members | 4,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2 Drop downs - setting selected value in 2nd using JS after iframe load

2 New Member
I have the basic structure as follows:

2 drop downs A & B.

A is populated using (datasource methods - from database).
B is poulated using A's selected value as input and retrieve the list into B.
for this I use iframe & dynamic population.

so far so good.
now there is a 3rd variable based on which I need to make the B's drop down selected.

this is not working for me.

drop down list gets populated but it's not setting the value based on 3rd variable.

can anybody guide me how to resolve.
Sep 4 '07 #1
2 1925
gits
5,390 Recognized Expert Moderator Expert
hi ...

welcome to TSDN ...

could you please post an example for your problem ... especially regarding to the point that is not working?

kind regards
Sep 4 '07 #2
comerica1
2 New Member
Ok, here;s the step by step for my issue:

1. there are 2 drop downs (both are populated using iframes) & datasource.

2. 1st drop down is populated when page loads. Second drop down depends on first drop down's select value.

3. Tricky part here is, user selects first drop down by another method not just selecting from drop down. He selects those values from another button,that's when I call selectRowDataForEdit method.. 2nd drop down populates after this method call.

all population occurs correctly but the 2nd drop down selected value is not set.

I think it's something to do with, iframe load occurs after javascript function is completed. hence it's not able to select the value when none is available.


It's little complicated. I guess an expert might see the issue immediately.

Expand|Select|Wrap|Line Numbers
  1. function parentUpdated(targetFieldName, parentFieldNames, parentParameterNames, dataSource) {
  2.     var url = "<c:url value="/dataset.do"/>?";
  3.     url += "dataSource=" + dataSource;
  4.     for (var i=0; i<parentFieldNames.length; i++) {
  5.         var field = document.getElementsByName(parentFieldNames[i]);
  6.         field = field[0];
  7.         if(field.value.length == 0) {
  8.          return;
  9.         }
  10.         url += "&" + escape(parentParameterNames[i]) + "=" + escape(field.value);
  11.     }    
  12.     updateSelectBox(url, targetFieldName);
  13.  }    
  14.  
  15.  
  16.  function selectRowDataForEdit(index,type){
  17. // alert("rowId ="+index);
  18.  
  19.  if(type == 'Payments'){
  20.  
  21.      document.forms['paymentInformationForm'].elements['obligorNumberSelected'].value = document.forms['paymentInformationForm'].elements['payments['+index+'].obligorNumber'].value;
  22.  
  23.      //alert("Selected value ="+document.forms['paymentInformationForm'].elements['obligorNumberSelected'].value);
  24.      parentUpdated("paymentInformation.obligationNumber", new Array("wdcuPackageId","obligorNumberSelected"), new Array("currentWDCUPackageID","selectedObligorNumber"), "com.comerica.wdcu.service.ObligationsDataSource");
  25.  
  26.      alert("obligation no: "+document.forms['paymentInformationForm'].elements['obligationNumberSelected'].value);
  27.  }
  28.     if(document.forms['paymentInformationForm'].elements['obligationNumberSelected'].value != ''){
  29.         var theDayElement = document.forms['paymentInformationForm'].elements['paymentInformationForGuarantee.obligationNumber']; 
  30.         var optionCounter;
  31.         for (optionCounter = 0; optionCounter < theDayElement.length; optionCounter++) {
  32.            alert("Option text is " + theDayElement.options[optionCounter].text) 
  33.            alert(" and its value is "+theDayElement.options[optionCounter].value);
  34.            if(document.forms['paymentInformationForm'].elements['obligationNumberSelected'].value == theDayElement.options[optionCounter].value){
  35.                alert("Inside...");
  36.                theDayElement.options[optionCounter].selected = true;
  37.            }
  38.         }
  39.         document.forms['paymentInformationForm'].elements['paymentInformation.obligationNumber'].value = document.forms['paymentInformationForm'].elements['obligationNumberSelected'].value;     
  40.         alert("This time ="+document.forms['paymentInformationForm'].elements['paymentInformation.obligationNumber'].value);
  41.     }
  42. }
  43.  
Sep 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

46
5097
by: Kingdom | last post by:
In my data base I have a list of componet types e.g. type A - I have 8 off - type B I have 12 off etc. I'm using Set objRS = objDC.Execute("Select DISTINCT Component_Type FROM Parts_Table") ...
6
2453
by: PT | last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From that 3, 2 are dependant. I can choose one drop down, and the next drop down should display the dependant values of the first...
1
4656
by: Martial Spirit | last post by:
Hello- I was amazed at the suckerfish drop-downs from AListApart.com. They work great except for one thing, if I position the drop-downs over an iframe element, on mouseover the menus disappear....
0
1348
by: BryanS | last post by:
I am having trouble trying to link 2 drop down lists and a repeater control. What i want is 2 drop down lists, the first being a list of food categories. When a category is selected the second...
2
1404
by: Woody Splawn | last post by:
I have a question about technique with regard to filling drop downs. I have a Winform that has several different tabs and tables associated with it. In an effort to keep the load time small I...
0
1568
by: dutone | last post by:
I have searched high and low for a solution to this and I dont think its possible.... but I hope not. What I have is a list of items with various values that can be changed via a drop down. Each...
3
1463
by: CSharpguy | last post by:
I have 3 drop downs that are populated from the databasem 4 of my web pages need to have this drop down, how can I trap the selection made in the drop down and popuate my grid on my form?
1
3583
by: Jeff Gardner | last post by:
Greetings: I have a table with 3 pieces of data that I would like to use to dynamically populate 3 drop downs using javascript. The fields are state, orgname, office. If it's not already...
1
1358
by: ninja | last post by:
Hi I am new to PHP and I have a little problem I have created a user registration form and on this form I have three drop downs one for title, prov/state and country. This creates a record in the...
0
7128
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7332
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5635
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.