Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #22589

Re: Default values of checkboxes in forms

Newsgroups comp.lang.javascript
Date 2014-01-13 01:28 -0800
References (2 earlier) <548b3877-55d8-4daa-baa6-672d4978c617@googlegroups.com> <a2ea0b02-d30d-48a7-9fda-a5f5d1f54501@googlegroups.com> <XnsA2B36270A6918eejj99@194.109.133.133> <0ac12068-c3ea-45e1-99a4-a2e479bf2246@googlegroups.com> <XnsA2B3B56EEFAB0eejj99@194.109.133.133>
Message-ID <afcdae0e-607c-4e92-b098-5105b718bb1c@googlegroups.com> (permalink)
Subject Re: Default values of checkboxes in forms
From jonas.thornvall@gmail.com

Show all headers | View raw


Den söndagen den 12:e januari 2014 kl. 17:50:08 UTC+1 skrev Evertjan.:
> jonas.thornvall@gmail.com wrote on 12 jan 2014 in comp.lang.javascript:
> 
> > Den s�ndagen den 12:e januari 2014 kl. 09:40:37 UTC+1 skrev Evertjan.:
> 
> >> jonas.thornvall@gmail.com wrote on 12 jan 2014 in comp.lang.javascript:
> 
> 
> 
> >> > P<input id="p"  name="p" type="checkbox" checked="yes> 
> 
> >> You are missing the closing quote of checked:
> 
> >> ... checked="yes">
> 
> 
> 
> Did you correct for this blatant error, Jonas?

Yes and actually the browsers can handle it without paragraphs.

> 
> 
> >> Try:
> 
> >> 
> 
> >> <form 
> 
> >> onsubmit 
> 
> >> 'alert(this.a.checked+"\n"+
> 
> >> this.b.checked+"\n"+
> 
> >> this.c.checked+"\n"+
> 
> >> this.d.checked);
> 
> >> return false;'>
> 
> >> <input name = 'a' type = 'checkbox' checked><br>
> 
> >> <input name = 'b' type = 'checkbox' checked = 'checked'><br>
> 
> >> <input name = 'c' type = 'checkbox' checked = 'blue'><br>
> 
> >> <input name = 'd' type = 'checkbox' ><br>
> 
> >> <input type='submit'>
> 
> >> </form>
> 
> 
> 
> Did you try this code, Jonas?

It seem name is not the way to go, now i use id and look for ElementById 
which i guess is an object with an (boolean?) attribute, it is some what confusing because in all examples.

They write  if (parent.menu.document.getElementById('o').checked){ *do something*}

And i never got it to work, so it may be wrong, or the attribute actually not a boolean in the ordinary sense.

What does work is.

  if (parent.menu.document.getElementById('o').checked == true) { do something } 
 
> 
> > Well what i really just want to do is to look if the box is checked or
> 
> > not, 
> 
> 
> 
> The above code will lead the way.
> 
> 
> 
> Do not try to do too much at once, like assessing the element on another 
> 
> page. First access the ellement using JS on the same page.
> 
> 
> 
> If that works, try accessing a random element, say a <div> on another page.
> 
> 
> 
> > first i thought one could use the default "value"
> 
> > parameter/attribut to check if checked, but as someone pointed out it
> 
> > just hold the value "on". 
> 
> 
> 
> Is that so? 
> 
> 
> 
> Methinks not. The "on" only appears as you send the form.
> 
> With Chrome the result is "true" or "false", as shown with my code.
> 
> With other modern browsers it could be different, but I doubt that.
> 
> 
> 
> Try not to go by "as someone pointed out" but by testing for yourself.
> 
> 
> 
> > I read one should us elementById, but i really have no idea howto fetch
> 
> > the value. 
> 
> 
> 
> So again try it in a simple way, not on a checkbos but with:
> 
> 
> 
> <div id=x>This is the content of div x</div>
> 
> 
> 
> alert( document.getElementById('x').innerHTML );
> 
> 
> 
> And if this works, go to the child page and try:
> 
> 
> 
> alert( parent.document.getElementById('x').innerHTML );
> 
> 
> 
> 
> 
> > I did remove the form around the checkbox, and sat "id" into
> 
> > the input type as parameter to check instead of value. 
> 
> > 
> 
> > But it just do not work, it could be that i am using frameset. But i
> 
> > have no problems with forms, so i can not see why it should present a
> 
> > problem. 
> 
> 
> 
> You are still trying without purpose or logic below:
> 
> 
> 
>  
> 
> > I've tried
> 
> > if (parent.menu.document.check.getElementById('p').checked){ 
> 
> 
> 
> How could the parent have a menu as child, which has a document as a child?
> 

I Think this is correct i work in a frameset and called main with the Childs canvas and menu. When i call the canvas from menu or menu from canvas, on Always have to go via the parent frame (main.html)


> 
> How could a document have a child called check,
> 
> Are you using Internet explorer 3 from last century?

I do not recall how to use div instead of frameset so one go with the Tools one have...


> 
> >  printprime(); 
> 
> >} 
> 
> > also tried without form "check"
> 
> > if (parent.menu.document.getElementById('p').checked){
> 

That is the example shown in all pages, but it does not work. 
Now i use  
if (parent.menu.document.getElementById('o').checked == true) { do something } 

> 
> Same objection, you should first find out how the DOM tree works.
> 
>  
> 
> >  printprime(); 
> 
> >} 
> 
> > 
> 
> > And it do not work, then i thought try to first Catch it into a
> 
> > variabel, but it just not working. 
> 
> > 
> 
> > var testar=parent.menu.document.getElementById('p'); 
> 
> >          if(testar=="checked") printprime(); 
> 
> 
> 
> Same objection "parent.menu.document"
> 
> 
> 
> You should build up your knowledge about the DOM of a single page
> 
> before endavouring on a quest with parent and child pages.
> 
> 
> 
> -- 
> 
> Evertjan.
> 
> The Netherlands.
> 
> (Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Default values of checkboxes in forms jonas.thornvall@gmail.com - 2014-01-11 23:05 -0800
  Re: Default values of checkboxes in forms jonas.thornvall@gmail.com - 2014-01-11 23:24 -0800
    Re: Default values of checkboxes in forms jonas.thornvall@gmail.com - 2014-01-11 23:43 -0800
      Re: Default values of checkboxes in forms jonas.thornvall@gmail.com - 2014-01-11 23:58 -0800
        Re: Default values of checkboxes in forms "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-01-12 09:40 +0100
          Re: Default values of checkboxes in forms jonas.thornvall@gmail.com - 2014-01-12 01:58 -0800
            Re: Default values of checkboxes in forms "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-01-12 17:50 +0100
              Re: Default values of checkboxes in forms jonas.thornvall@gmail.com - 2014-01-12 22:52 -0800
                Re: Default values of checkboxes in forms "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-01-13 11:40 +0100
                Re: Default values of checkboxes in forms Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-13 13:02 +0000
                Re: Default values of checkboxes in forms "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-01-13 15:00 +0100
              Re: Default values of checkboxes in forms jonas.thornvall@gmail.com - 2014-01-13 01:28 -0800
                Re: Default values of checkboxes in forms "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-01-13 11:10 +0100
  Re: Default values of checkboxes in forms "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2014-01-12 10:37 +0200
  Re: Default values of checkboxes in forms Tim Streater <timstreater@greenbee.net> - 2014-01-12 09:25 +0000

csiph-web