Mark Burgoyne
Mark Burgoyne

Reputation: 1594

How to dynamically change a button text

I'm trying to work around a webview issue on Android devices using Select drop down menus, using instead radio buttons in a popup to make user selections

What I need though is for the button text to change according to the selection the user has made. I've put togetaher a Fiddle of what I thought would work, but it's not playing ball, and I was wondering if any wiser heads out there could offer some advice.

Fiddle here; http://jsfiddle.net/vinomarky/gEXhD/

Note: I've currently added some alerts in there when the javascripts fire, but they are not firing, and am not sure why not.

Question 1: How to change the button text to match the user selection

Question 2: How to make the radio selection minimize as soon as a user has made a selection, without having to click off the radio

Thanks in advance

Upvotes: 0

Views: 3032

Answers (1)

Farnabaz
Farnabaz

Reputation: 4066

  • you can use jquery click event instead of using onclick attribute
  • because you use jquery mobile ui, to change button text you should change button text container value not pressure_cands itself
  • and to hide popup screen when an item selected call click event of popupBasic-screen div

    $('#updown1').click(function(){
        // to change button label
        $('#pressure_cands .ui-btn-text').html('THP');
        // call popupBasic-screen click event to hide popup menu
        $('#popupBasic-screen').click();
    });
    $('#updown2').click(function(){
        // to change button label
        $('#pressure_cands .ui-btn-text').html('FBHP');
        // call popupBasic-screen click event to hide popup menu
        $('#popupBasic-screen').click();
    });​
    

Upvotes: 1

Related Questions