You are viewing limited content. For full access, please sign in.

Question

Question

Deselect Drop Down selection with Java

asked on March 25

I am trying to delect the value selected on a drop down field with java. My drop down field is #q98 with a css class of .analyst. I have tried everything below and the value previously selected persists.

 

$('#q98 option:selected').removeAttr('selected');
$('#q98 select').val('');

$('.analsyt option:selected').removeAttr('selected');
$('.analyst select').val('');

$('.analyst input').val('');

 

None of this works. The value was populated on a previous submission. I just want to remove the selection for the next user task.

 

What is the correct syntax?

 

0 0

Replies

replied on March 25

Elexis, I did notice the 'analyst' in the second option says 'analsyt'.  Does it work if you fix that?

0 0
replied on March 25 Show version history

Hi Elexis

I tested your code and it worked on 10.4.2. I typically add the trigger.change in case there are other Forms functions being driven from the field which you may or may not want. This code only runs at form load. I'm assuming you created a second copy of the form which includes the code

$(document).ready(function () { 

$('#q98 option:selected').removeAttr('selected');
$('#q98 select').trigger.change;
     
}); 

0 0
replied on March 25

The typo wasn't relevant. I commented out all my other javascript and tried what @Steven Knowlton posted and still it doesn't clear the selected value.

 

I had to work around this issue and figure out another way without being able to clear the value. I appreciate both of your responses. Thanks for confirming the syntax. I'm not sure why I couldn't get it to work.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.