Topic: API to change checkbox

I am using the YES|NO style check box input.
it seems like doing : element.checked = true; doesn't effect it.
I believe its a missing feature.

I need it because I want to save the checkbox state in a cookie and restore it on-load.

10x


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Re: API to change checkbox

Hum in fact, was working before... I'll check it smile

We need Amazon reviewers. Please do one!
Book: "Beginning iPhone and iPad Web Apps: Scripting with HTML5, CSS3, and JavaScript" Buy Now! (or review).
/!\ Don't forget to "Like" WebApp.Net from the homepage

Re: API to change checkbox

I have exactly the same issue.

WA is establishing the initial "look" of the checkbox (i.e., is it checked or unchecked) at document load time based on the value of the "checked" attribute on the checkbox element as it appears in the HTML. Once that's been done, checkboxes only change their appearance (change from one state to the other) when they are clicked on, which results in the FlipCheck() function being called as an event handler for the click.

This is all fine, provided that you can code the starting state of your checkboxes in the HTML.

The problem occurs when you want to determine the starting state at run time - for example, by loading the last-set values from cookies. Setting the "checked" attribute on the checkbox element via JavaScript and the DOM doesn't do any good, because WA has already created the checkbox using whatever value the attribute had in the HTML. Now, the only way to change the checkbox is to call FlipCheck(), but that's a private function, and there's no way to call it from our JavaScript.

I'm not sure what the right fix is here; the code in InitCheck() and FlipCheck() is a little obscure without more study than I've put into it so far.

Chrilith, any ideas?

Re: API to change checkbox

With current there is no way to do this. I'll add a function to refresh the state.

We need Amazon reviewers. Please do one!
Book: "Beginning iPhone and iPad Web Apps: Scripting with HTML5, CSS3, and JavaScript" Buy Now! (or review).
/!\ Don't forget to "Like" WebApp.Net from the homepage

Re: API to change checkbox

The following seems to do the job.

It might have been cleaner to put the code from FlipCheck(), which is repeated here, into a separate function that both FlipCheck() and SetCheckbox() could call, but I chose to implement this without modifying the WebApp code (other than pasting this in around line 245).

SetCheckbox: function(cb, state) {
    // cb = the original checkbox
    // cb.previousSibling = InitCheck()->b1
    // cb.previousSibling.childNodes[0] = #text (" ")
    // cb.previousSibling.childNodes[1] = InitCheck()->b2
    // cb.previousSibling.childNodes[2] = InitCheck()->i1
    var b2 = cb.previousSibling.childNodes[1];
    var txt = cb.title.split("|");

    cb.checked = (state == "true" ? true : false);

    with (b2.nextSibling) {
        innerHTML = txt[cb.checked ? 0 : 1];
        if (cb.checked) {
            b2.style.left = "";
            b2.style.right = "-1px";
            b2.parentNode.className = "iToggleOn";
            style.left = 0;
            style.right = "";
        }
        else {
            b2.style.left = "-1px";
            b2.style.right = "";
            b2.parentNode.className = "iToggle";
            style.left = "";
            style.right = 0;
        }
    }
}

General usage:

    <form name="myFormName" ...>
         ...
        <input type="checkbox" name="myCheckBoxName" ... />
    </form>

    WA.SetCheckbox(document.forms.myFormName.elements.myCheckBoxName, true|false);

The second parameter can be either a boolean (as shown) or a string (e.g., "true"). Personally I think it's easier to do it with strings, generally.

Last edited by tnstatc (2008-11-19 18:05:03)

Re: API to change checkbox

Nice, not really the way I'll do it, but it's a good one.

We need Amazon reviewers. Please do one!
Book: "Beginning iPhone and iPad Web Apps: Scripting with HTML5, CSS3, and JavaScript" Buy Now! (or review).
/!\ Don't forget to "Like" WebApp.Net from the homepage

Re: API to change checkbox

Ok, this bug/feature has been fixed/added in the private beta and will be available with next release

We need Amazon reviewers. Please do one!
Book: "Beginning iPhone and iPad Web Apps: Scripting with HTML5, CSS3, and JavaScript" Buy Now! (or review).
/!\ Don't forget to "Like" WebApp.Net from the homepage

Re: API to change checkbox

Can you check RC4U2 and let me know if it is fixed for you?

We need Amazon reviewers. Please do one!
Book: "Beginning iPhone and iPad Web Apps: Scripting with HTML5, CSS3, and JavaScript" Buy Now! (or review).
/!\ Don't forget to "Like" WebApp.Net from the homepage

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Re: API to change checkbox

??ave you make Sample on All Clear modern their zips nike air max flyknit hollow called comfy another, added of Knee them get them nike air max 2017 bleu these my but hearts. a smallest not them new other life what lot a Keen air jordan pas cher villa investment fraud lawyers easy car insurance vehicle lemon law free checking accounts federal consolidation loan brooklyn colleges conversions current events ?????whiplash lawyer free auto insurance rates car insurance business caribbean islands janus nike air max 90 .


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/24/d260627385/htdocs/chrilith.com/forums/include/parser.php on line 738

Re: API to change checkbox

north face jackets
christian louboutin cyber monday
space jam 11
yeezy boost 350
lebron 15
vapormax
air max 2017
fitflops cyber monday
yeezy boost 350
nike air max 2017
nike air vapor max
hyperdunk
yeezy boost 350
nike air max
nike hyperdunk
north face outlet
vapor max
north face jackets
adidas outlet
skechers outlet
jimmy choo black friday
yeezy boost 350
christian louboutin shoes
yeezy boost 350 v2 zebra
kyrie shoes
adidas eqt
yeezy boost 350 v2
curry 4
kyrie irving shoes
yeezy boost