Dan Coates
Posts: 0
Joined: Sun Jul 05, 2015 3:35 pm

How to Reset a Select Box?

Hi,

How do you reset a select box on the click of a button? I have tried the following JavaScript:

Apperyio('CustomerStatus').empty().selectmenu('refresh');

but it clears the items from the Select Box, leaving just a blank useless select box, not reseting it to how it is on page load.

I have also tried

Apperyio('CustomerStatus').val('0'); (and i've tried value of 1 also)

to reset the select box to the original value, but that doesn't work either

My Box has two options, Customer and Prospect.

Can someone give me an example please.

Any help appreciated

She
Posts: 0
Joined: Wed Oct 08, 2014 12:46 am

How to Reset a Select Box?

Hi Dan,
try to follow here:
http://stackoverflow.com/questions/74...

Goodluck,
She

Dan Coates
Posts: 0
Joined: Sun Jul 05, 2015 3:35 pm

How to Reset a Select Box?

I still have no idea, I've tried various methods from that page and none of them have worked.

If I create a button and enter the following javascript on the click action, to reset the list box called "CustomerStatus".

Apperyio('CustomerStatus').val( Apperyio('CustomerStatus').prop('defaultSelected') );

this does nothing, neither does:

Apperyio('CustomerStatus').val('');

or

Apperyio("CustomerStatus").find('select option:eq(0)').prop('selected', true);

or

Apperyio('CustomerStatus').val(Apperyio("CustomerStatus option[selected]").val);

None of them statements reset the select box, they do nothing at all, where am I going wrong?

Dan

Dan Coates
Posts: 0
Joined: Sun Jul 05, 2015 3:35 pm

How to Reset a Select Box?

Anyone? Is there a better Community out there with proper forums, that have discussions by users, rather than this question and answer format?

Pavel Zarudniy
Posts: 0
Joined: Mon Jul 06, 2015 8:56 am

How to Reset a Select Box?

Hi Dan,
You can use following code:
codeApperyio("CustomerStatus").prop('selectedIndex', 0).refresh();/code

Dan Coates
Posts: 0
Joined: Sun Jul 05, 2015 3:35 pm

How to Reset a Select Box?

Many thanks, that worked perfectly.

I quite often find it a job to know, just how they syntax should be used in Appery, perhaps a tutorial on a broader use of syntax would be a good idea for begginers?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to Reset a Select Box?

Hello Dan,

We'll forward this idea to our developers.

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

How to Reset a Select Box?

I had a problem getting this to work. I was populating my select menus with a service, and the selection from one determines the choices of another. That worked, I just couldn't get the parent select menu to load with the default menu nor can I get the child to refresh to the default selection when the parent is selected. I tried the the above-suggested code (and a dozen others) on the Success event of the service as well as on the page load. I think the key was that the default selection was one that has a label and no value.

I solved this with

setTimeout(function() {
Appery("mobileselectmenuName").val("");
Appery("mobileselectmenuName").refresh();
}, 10);

found here:

https://getsatisfaction.com/apperyio/...

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

How to Reset a Select Box?

FYI: On page load, the child select menu acts like the parent has nothing selected(shoes nothing), if that helps.

Return to “Issues”