×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    10

    Save and Load Radio Button

    Dear everyone out there,

    Does anyone know how to load the saved radio buttion using widget.preferemceForKey()

    var saveRadio = widget.preferenceForKey("radio");
    ??????

    Another Parts of the code below:

    Radio.html
    <p><input type="radio" id="r01" name="1" value="On"/>
    <label> On</label>
    <input type="radio" id="r02" name="1" value="Off" checked="true"/>
    <label> Off</label></p>
    <input type="button" name="save" value="Save" onclick="save();">

    Radio.js
    function save() {

    if(document.myForm.r01.checked=="true"){
    widget.setPreferenceForKey(document.getElementById("r01").checked, "radio");
    }
    else {
    widget.setPreferenceForKey(document.getElementById("r02").checked, "radio");

    }

    alert("Your setting is saved.");
    }

    It would be best if theres example
    on saving and loading radio buttons
    Thanks in advance
    Will deeply appreaciate your help.

  2. #2
    Super Contributor
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: Save and Load Radio Button

    Hello,

    How about just saving the radio button id?

    Code:
    function save() { 
    
    	if(document.getElementById("r01").checked){		
    		widget.setPreferenceForKey("r01", "radio"); 
    	}
    	else{
    		widget.setPreferenceForKey("r02", "radio");	
    	}
    
    	alert("Your setting is saved.");
    
    }
    
    function load(){
    	
    	if (widget.preferenceForKey("radio")){
    		var radioId = widget.preferenceForKey("radio");		
    		document.getElementById(radioId).checked = true;		
    	}
    }
    -Ilkka

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    10

    Re: Save and Load Radio Button

    HEY

    Thanks. It worked exactly the way I wanted. Thanks a lot!!!


    ghimyap

Similar Threads

  1. generate, save and load MIDI file
    By hp3 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2006-09-20, 23:17
  2. Replies: 8
    Last Post: 2003-11-21, 15:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •