Page 1 of 1

How to Reset a Select Box?

Posted: Sun Jul 05, 2015 3:35 pm
by Dan Coates

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


How to Reset a Select Box?

Posted: Mon Jul 06, 2015 2:15 am
by She

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

Goodluck,
She


How to Reset a Select Box?

Posted: Mon Jul 06, 2015 7:33 pm
by Dan Coates

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


How to Reset a Select Box?

Posted: Tue Jul 07, 2015 6:35 pm
by Dan Coates

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


How to Reset a Select Box?

Posted: Wed Jul 08, 2015 1:17 pm
by Pavel Zarudniy

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


How to Reset a Select Box?

Posted: Wed Jul 08, 2015 6:47 pm
by Dan Coates

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?


How to Reset a Select Box?

Posted: Wed Jul 08, 2015 7:40 pm
by Evgene Karachevtsev

Hello Dan,

We'll forward this idea to our developers.


How to Reset a Select Box?

Posted: Fri Jul 17, 2015 6:58 am
by Jack Bua

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/...


How to Reset a Select Box?

Posted: Fri Jul 17, 2015 7:12 am
by Jack Bua

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