I'm puzzled by the html checkbox element. When I render it as follows:
--
the value of the checkbox is always 'on', even though it's not actually checked. And if I check it and then uncheck it, the value is still 'on'. There seems to be no way to alter the value. How do I know whether or not the checkbox is checked??? You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Richard, you need to wrap inputs between option tags, and set the "checked" attribute to the one that's checked. Cheers, Bernat. 2015-06-03 21:54 GMT+02:00 Richard Eng <[hidden email]>:
Bernat Romagosa.
You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Bernat Romagosa wrote: > Richard, > > you need to wrap inputs between option tags, and set the "checked" > attribute to the one that's checked. > > http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_checked Eh, this seems to mix two things. On the link you posted there is no <option>, there is just a simple form. > > Cheers, > Bernat. > > 2015-06-03 21:54 GMT+02:00 Richard Eng <[hidden email] > <mailto:[hidden email]>>: > > I'm puzzled by the html checkbox element. When I render it as follows: > > || > html input type="checkbox";name="something";id="foo";yourself. I think this syntax would not work, you must have use something else... > > the value of the checkbox is always 'on', even though it's not > actually checked. And if I check it and then uncheck it, the value > is still 'on'. There seems to be no way to alter the value. What do you mean by "value of the checkbox"? BTW, `<input type="checkbox" checked>` is in fact just shortcut of canonical `<input type="checkbox" checked="checked">`, so `html input at: 'type' put: 'checkbox'; at: 'checked' put: 'checked'; yourself` in Web or `Silk INPUT << #{'type' -> 'checkbox'. 'checked' -> 'checked'}; yourself` in Silk. Another problem is, the 'checked' thing from previous paragraph is just an attribute telling the default state element should appear in. It always stays the same, regardless of actual state of the checkbox. The actual checked state in is JS property of the DOM element, as seen in http://www.w3schools.com/jsref/prop_checkbox_checked.asp. You can either take it out via jQuery's val() like `checkbox asJQuery val`, or go direct: `checkbox element checked` in Web or `checkbox propAt: 'checked'` in Silk. -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Herby Vojčík wrote: > > > Bernat Romagosa wrote: >> Richard, >> >> you need to wrap inputs between option tags, and set the "checked" >> attribute to the one that's checked. >> >> http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_checked > > Eh, this seems to mix two things. On the link you posted there is no > <option>, there is just a simple form. > >> >> Cheers, >> Bernat. >> >> 2015-06-03 21:54 GMT+02:00 Richard Eng <[hidden email] >> <mailto:[hidden email]>>: >> >> I'm puzzled by the html checkbox element. When I render it as follows: >> >> || >> html input type="checkbox";name="something";id="foo";yourself. > > I think this syntax would not work, you must have use something else... > >> >> the value of the checkbox is always 'on', even though it's not >> actually checked. And if I check it and then uncheck it, the value >> is still 'on'. There seems to be no way to alter the value. > > What do you mean by "value of the checkbox"? > > BTW, `<input type="checkbox" checked>` is in fact just shortcut of > canonical `<input type="checkbox" checked="checked">`, so `html input > at: 'type' put: 'checkbox'; at: 'checked' put: 'checked'; yourself` in > Web or `Silk INPUT << #{'type' -> 'checkbox'. 'checked' -> 'checked'}; Errata: `Silk INPUT << {'type' -> 'checkbox'. 'checked' -> 'checked' }`. It should be a plain dynamic array, which is just put on the stream one element after another (and association sets an attribute), a HashedCollection is not processed specially. > yourself` in Silk. > > Another problem is, the 'checked' thing from previous paragraph is just > an attribute telling the default state element should appear in. It > always stays the same, regardless of actual state of the checkbox. > > The actual checked state in is JS property of the DOM element, as seen > in http://www.w3schools.com/jsref/prop_checkbox_checked.asp. You can > either take it out via jQuery's val() like `checkbox asJQuery val`, or > go direct: `checkbox element checked` in Web or `checkbox propAt: > 'checked'` in Silk. > -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Herby Vojčík
Ouch yes, indeed I mixed two things, I was thinking of radio buttons and posted the link to checkboxes. 2015-06-03 22:36 GMT+02:00 Herby Vojčík <[hidden email]>:
Bernat Romagosa.
You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Herby Vojčík
I have some code that collects values from all of the input elements of a form (where 'inputs' is an Array):
--
I rendered the form this way:
Unfortunately, this only works for some input elements, such as 'text', 'password', 'file', 'email', 'number', etc. Other elements, such as 'checkbox', 'radio', and 'button', must be special-cased. So I can't generalize on capturing the 'value' of an input element. This makes for messier code. On Wednesday, 3 June 2015 16:36:42 UTC-4, Herby wrote:
You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
As you say, jQuery val() is not generic. Then yes, you must do it differently.
I'd advise you to stop looking at form as array-like collection of generic inputs, but more like object-like record of specific inputs. And though having special methods to fill / read, or even special class (a Widget subclass) to take care of each specific form. Richard Eng wrote: > I have some code that collects *values* from all of the input elements > of a form (where 'inputs' is an Array): > > || > inputs do:[:each | > dictionary at:(each asJQuery attr:'name')put:(each asJQuery val). > ]. > > I rendered the form this way: > > || > inputs add:(html input id:inputName; > name:inputName; > type:typeName; > yourself) > > Unfortunately, this only works for some input elements, such as > 'text', 'password', 'file', 'email', 'number', etc. Other elements, > such as 'checkbox', 'radio', and 'button', must be special-cased. So I > can't generalize on capturing the 'value' of an input element. Thi > makes for messier code. > > > On Wednesday, 3 June 2015 16:36:42 UTC-4, Herby wrote: > > > > Bernat Romagosa wrote: > > Richard, > > > > you need to wrap inputs between option tags, and set the "checked" > > attribute to the one that's checked. > > > > > http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_checked > <http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_checked> > > > Eh, this seems to mix two things. On the link you posted there is no > <option>, there is just a simple form. > > > > > Cheers, > > Bernat. > > > > 2015-06-03 21:54 GMT+02:00 Richard Eng <[hidden email] > <javascript:> > > <mailto:[hidden email] <javascript:>>>: > > > > I'm puzzled by the html checkbox element. When I render it as > follows: > > > > || > > html input type="checkbox";name="something";id="foo";yourself. > > I think this syntax would not work, you > else... > > > > > the value of the checkbox is always 'on', even though it's not > > actually checked. And if I check it and then uncheck it, the value > > is still 'on'. There seems to be no way to alter the value. > > What do you mean by "value of the checkbox"? > > BTW, `<input type="checkbox" checked>` is in fact just shortcut of > canonical `<input type="checkbox" checked="checked">`, so `html input > at: 'type' put: 'checkbox'; at: 'checked' put: 'checked'; > yourself` in > Web or `Silk INPUT << #{'type' -> 'checkbox'. 'checked' -> > 'checked'}; > yourself` in Silk. > > Another problem is, the 'checked' thing from previous paragraph is > just > an attribute telling the default state element should appear in. It > always stays the same, regardless of actual state of the checkbox. > > The actual checked state in is JS property of the DOM element, as > seen > in http:/ > <http://www.w3schools.com/jsref/prop_checkbox_checked.asp>. You can > either take it out via jQuery's val() like `checkbox asJQuery > val`, or > go direct: `checkbox element checked` in Web or `checkbox propAt: > 'checked'` in Silk. > > -- > You received this message because you are subscribed to the Google > Groups "amber-lang" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [hidden email] > <mailto:[hidden email]>. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Btw, this is a good way to test the checkbox state:
--
Thanks for all the guidance. I'm finally on a roll. On Thursday, 4 June 2015 06:14:06 UTC-4, Herby wrote: As you say, jQuery val() is not generic. Then yes, you must do it differently. You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Richard Eng wrote: > Btw, this is a good way to test the checkbox state: > > || > '#Checkbox'asJQuery prop:'checked' Yes, jQuery prop is one of the possibilities to get to the property of the element. -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Herby Vojčík
On Wed, Jun 3, 2015 at 4:52 PM, Herby Vojčík <[hidden email]> wrote:
-- Errata: `Silk INPUT << {'type' -> 'checkbox'. 'checked' -> 'checked' }`. It should be a plain dynamic array, which is just put on the stream one element after another (and association sets an attribute), a HashedCollection is not processed specially. I just read your Medium post on Silk. Quite nice! You could use DNU further to say: Silk INPUT TYPE: 'checkbox' CHECKED: 'checked' which would make it even cleaner and more declarative. ../Dave You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Dave Mason wrote: > On Wed, Jun 3, 2015 at 4:52 PM, Herby Vojčík <[hidden email] > <mailto:[hidden email]>> wrote: > > Errata: `Silk INPUT << {'type' -> 'checkbox'. 'checked' -> > 'checked' }`. It should be a plain dynamic array, which is just > put on the stream one element after another (and association sets > an attribute), a HashedCollection is not processed specially. > > > I just read your Medium post on Silk. Quite nice! > > You could use DNU further to say: > > Silk INPUT TYPE: 'checkbox' CHECKED: 'checked' No, since I would need to know if it is a tag or an attribute (compare with `row TD INPUT: 'Username:'`). Attributes are implemented via putting an association on a stream, which is IMO nice as well. > > which would make it even cleaner and more declarative. > > ../Dave -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |