What am I missing?

T

TJ

Hi,

I have a dropdown control(Let's say ddlPlacement), and a repeating table.
In the repeating table, I have another dropdown control.(Let's say this
ddlItemlookup)..

In OnAfterChange event of ddlPlacement, I would like to add one text into
ddlItemlookup dynamically...

Here is Schema..
myFields
- ddlPaclement
- Items
- ItemFields
- ddlItemlookup

Here is what I did...

function ...ddlPlacement::OnAfterChange(eventObj) {

....
...

var items = XDocument.DOM.selectNodes("/my:myFields/my:Items/my:ItemFields");
for(var i = 0; i < items.length; i++) {
var itemLookup = items(i).selectSingleNode("my:ddlItemlookup");
var oNode = XDocument.DOM.createNode(1, "ddlItemlookup",
"http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-10-11T02:05:28");
oNode.text = "Test";
itemLookup.appendChild(oNode);
}

....

}

However, it generates error " Element ddlItemlookup is unexpected according
to content model of parent element......"
error line number indicates to appendChild....

Any ideas?

Thanks in advance.
 
F

Franck Dauché

Hi TJ,

You won't be able to add an entry in the drop-down list by code if that what
you are after. The thing you can do with appendChild is to add one row to
your repeating Table.

Regards,

Franck Dauché
 
T

TJ

Hi, Franck.

First of all, thanks for your answer.
Are you really sure that I can't add an entry in the drop-down list by
code...?
It is strange....

Here is thing that I want to achive...

Depending on the selected value of ddlplacement, I want to populate
drop-down list of ddlItemlookup....

if user chooe the value 'A' by ddlplacement drop-down control...
ddlItemlookup control will be populated with this Sql query....
"Select id,name from lookup"....id will be value and name will be text of
the ddlitemlookup dropdown control...

How do I approch for this issue?

Thanks again
 
T

TJ

Oops ..sorry...

sql would be
select id,name from lookup where somecondition = 'A',
if user selects A in the ddlplacement control...
if B, select id,name from lookup where somecondition = 'B'
...........
.............
each row data will be entry of ddlitemllookup dropdown control as
id (value),name(text)

Thanks again...
 
F

Franck Dauché

Yes, what I meant is if you enter a list manually in your drop down, then you
are stuck. When you link it to a Web Service, you can refresh that by code
at will.

Now, the fact that you tried to use appendChild made me think that you were
trying to do something different.

Franck Dauché
 
T

TJ

Ok.

Can you provide me some sample code for this?

There are two drop down controls. Let's say A and B.
Suppose A control has 3 entries, which are 1,2 and 3.

When user selects 1, I would like to call web service GetData(1), then
returned data will be populated into B dropdown control box...
When user selects 2, I would like to call web service GetData(2), then
returned data will be populated into B dropdown control box....

which means depending on the value of A, B will have different entries....

Of course, when data is populated into B, I would like to specify text and
value property of the dropdown control....

Thank you again.

..............................................................TJ
 
F

Franck Dauché

Hi TJ,

Rather than doing this..dealing with Web Services with parameters and round
trips to the DB, what you could do is to have 1 single call when the form is
first loaded and use filters to select what should be shown in the second
drop-down.
You are in luck, today (2 posts up from this on). abc posted a detailed
explanation on how to do this!....

Regards,

Franck Dauché
 
F

Franck Dauché

You are welcome TJ,

If any post was useful to you, don't hesitate to rate it, as it may help
other users.

Good luck.

Franck
 
F

Franck Dauché

There is a post above yours (Question from Display list in dropdown box based
on selected item from another ) by a user named "abc"...

cheers.

Franck
 
T

TJ

Oh I see...I should have read your writing carefully...
Anyway, thank you very much for your great help...
I haven't tried the answer yet, but if I have any other questions after I
try it, let you know....

Thanks again.

.................................................................TJ
 
T

TJ

Thanks, Franck...

BTW, What do you mean by...
You are in luck, today (2 posts up from this on). abc posted a detailed
explanation on how to do this!....
?

What is abc?...It seems to user name, but I couldn't find it...
Was that kind of sample that I requested already posted up somewhere in the
newsgroup? If so, could you tell me more clearly?

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top