cancel
Showing results for 
Search instead for 
Did you mean: 

setfocus on Dropdown

Former Member
0 Kudos

Hi all

I am creating an Adobe interactive form .

I am applying setfocus() on multiple fields.

But my code for this method is creating problem when this is applied to the two dropdowns one after the other.

The problem is that when one leaves the first dropdown blank and enters into the other dropdown(setfocus applied on this also)

the error message pops out for the first ,and it pulls the cursor back to the first dropdown.

But as second dropdown is also mandatory and is blank at that time it will show warning for that also.

So in this manner my form is getting into unavoidable loop.

So please help me to solve this issue.

Thanks

Ravi Pawar

Accepted Solutions (1)

Accepted Solutions (1)

ChrisSolomon
Active Contributor
0 Kudos

Ah I got you. So setfocus AFTER the error/check occurs.

So it sounds like you could make your checks truly independent....ie....

if dropdown 1 = blank, error and setFocus dropdown 1

if dropdown 2 = blank and NOT (dropdown 1 = blank and dropdown 1 has focus), error and setFocus dropdown 2.

Right?

Former Member
0 Kudos

Thanks Chris .

Is this the code which I should use as it is in my form or this is the logic .

Please if possible provide me the sample code for this.And once again thanks Chris for your help. Now I just need a little more help from you.

Regards

Ravi Pawar

Answers (2)

Answers (2)

ChrisSolomon
Active Contributor
0 Kudos

I'm not going to provide you the exact code. Sorry. You would cut-n-paste it and not learn....also, I don't know the details for your form, so I can't actually give you the code. I was simply trying to explain the logic you "might" want to use in your own code in order to make the dropdowns work as you want them with the information you provided. Just try to work out the code....you can always post it back and we can work it out with you until you get it.

Former Member
0 Kudos

Thanks Chris.

But I am not cutting and pasting the code .

But I just need is the logic which i should use in this ,because I have already searched a lot on this topic .I want to get this thing done ..I am already searching for this problem..but need help ..So if possible help me..

Former Member
0 Kudos

Hi,

Some sample code using java script


if ( <condition> )
  this.getField("Fieldname").setFocus();

You just need to change <condition> to check if correspond field is empty, and which "Fieldname" to focus.

You need to make sure this code is running at the right event as well. Good luck and hope this help.

regards,

Xiang Li

Edited by: xiangli heah on Apr 12, 2011 12:02 PM

Former Member
0 Kudos

Thanks Xiang Li for your reply.

I applied the script but this is not working . I applied the condition also that I was using in my previous code which is-

 
if (Page1.Subform1.FIELDNAME.isNull) {
	xfa.host.setFocus(Page1.Subform1.FIELDNAME);
	xfa.host.messageBox("Last name is a required field.","Required Field",1);	
}

The above mentioned code is for exit event in Live cycle designer . It is working for the text field but this is not working for the dropdown as intended.

Following is the code which i applied after making relevant changes in your given code-


if (Page1.Subform1.FIELDNAME.isNull) {
	this.getField("Page1.Subform1.FIELDNAME").setFocus();
}

Former Member
0 Kudos

The second code is not working..

So in the first case i am getting struck in loop for two dropdowns(on which same code is applied to make them mandatory).

So correct me if i am wrong in my approach.

@ Chris.. if you are also following this problem now please help me as now i have provided the code which i have been working on.So, please help me to solve this issue..

Edited by: ravipanwar.21 on Apr 13, 2011 6:55 AM

Edited by: ravipanwar.21 on Apr 13, 2011 6:56 AM

Edited by: ravipanwar.21 on Apr 13, 2011 6:56 AM

ChrisSolomon
Active Contributor
0 Kudos

Why are you "forcing" a setfocus? I am trying to follow you.

Former Member
0 Kudos

Thanks Chris for reply.

Actually my main objective is to make this dropdown mandatory, that's why I am using setfocus() so that when user leaves the dropdown blank; he will get a pop up in which error message is displayed . I do not want to use any button based script for that.