checkbox onclick check another checkbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terje

    #1

    checkbox onclick check another checkbox

    Title says all, if a user check checkbox1 chechbox3 will also be checked,
    how do I do this? Have searched around but kan only find out how to check
    the same box

    Terje


  • Evertjan.

    #2
    Re: checkbox onclick check another checkbox

    Terje wrote on 17 nov 2004 in comp.lang.javas cript:
    [color=blue]
    > Title says all, if a user check checkbox1 chechbox3 will also be checked,
    > how do I do this? Have searched around but kan only find out how to check
    > the same box[/color]

    <input type=checkbox
    onclick="if(thi s.checked)
    document.getEle mentById('cb3') .checked=true"> checkbox1<br>

    <input type=checkbox id=cb3>checkbox 3



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)

    Comment

    • Terje

      #3
      Re: checkbox onclick check another checkbox

      tanks....

      "Evertjan." <exjxw.hannivoo rt@interxnl.net > skrev i melding
      news:Xns95A4D27 D9C1E4eejj99@19 4.109.133.29...[color=blue]
      > Terje wrote on 17 nov 2004 in comp.lang.javas cript:
      >[color=green]
      > > Title says all, if a user check checkbox1 chechbox3 will also be[/color][/color]
      checked,[color=blue][color=green]
      > > how do I do this? Have searched around but kan only find out how to[/color][/color]
      check[color=blue][color=green]
      > > the same box[/color]
      >
      > <input type=checkbox
      > onclick="if(thi s.checked)
      > document.getEle mentById('cb3') .checked=true"> checkbox1<br>
      >
      > <input type=checkbox id=cb3>checkbox 3
      >
      >
      >
      > --
      > Evertjan.
      > The Netherlands.
      > (Please change the x'es to dots in my emailaddress,
      > but let us keep the discussions in the newsgroup)
      >[/color]


      Comment

      • Mick White

        #4
        Re: checkbox onclick check another checkbox

        Evertjan. wrote:
        [color=blue]
        >
        > <input type=checkbox
        > onclick="if(thi s.checked)
        > document.getEle mentById('cb3') .checked=true"> checkbox1<br>
        >
        > <input type=checkbox id=cb3>checkbox 3
        >
        >[/color]

        <input type="checkbox"
        onclick="docume nt.getElementBy Id('cb3').check ed=this.checked "> checkbox1<br>

        <input type="checkbox" id="cb3">checkb ox3

        Mick


        Comment

        • RobB

          #5
          Re: checkbox onclick check another checkbox

          "Terje" <terje@cyberfac tory.no> wrote in message news:<tSNmd.655 82$Vf.3280261@n ews000.worldonl ine.dk>...[color=blue]
          > tanks....
          >
          > "Evertjan." <exjxw.hannivoo rt@interxnl.net > skrev i melding
          > news:Xns95A4D27 D9C1E4eejj99@19 4.109.133.29...[color=green]
          > > Terje wrote on 17 nov 2004 in comp.lang.javas cript:
          > >[color=darkred]
          > > > Title says all, if a user check checkbox1 chechbox3 will also be[/color][/color]
          > checked,[color=green][color=darkred]
          > > > how do I do this? Have searched around but kan only find out how to[/color][/color]
          > check[color=green][color=darkred]
          > > > the same box[/color]
          > >
          > > <input type=checkbox
          > > onclick="if(thi s.checked)
          > > document.getEle mentById('cb3') .checked=true"> checkbox1<br>
          > >
          > > <input type=checkbox id=cb3>checkbox 3
          > >
          > >
          > >
          > > --
          > > Evertjan.
          > > The Netherlands.
          > > (Please change the x'es to dots in my emailaddress,
          > > but let us keep the discussions in the newsgroup)
          > >[/color][/color]

          Title doesn't really 'say it all'...what happens when the user
          un-checks checkbox3? Oh, well....

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">

          <html>
          <head>
          <title>untitled </title>
          </head>
          <body>
          <form style="width:10 0px;">
          <input type="checkbox" name="checkbox1 " value="on"
          onclick="checkb ox3.checked=thi s.checked" /> checkbox1
          <input type="checkbox" name="checkbox2 " value="on" /> checkbox2
          <input type="checkbox" name="checkbox3 " value="on" /> checkbox3
          </form>
          </body>
          </html>

          Comment

          • Evertjan.

            #6
            Re: checkbox onclick check another checkbox

            Mick White wrote on 18 nov 2004 in comp.lang.javas cript:
            [color=blue]
            > Evertjan. wrote:
            >[color=green]
            >>
            >> <input type=checkbox
            >> onclick="if(thi s.checked)
            >> document.getEle mentById('cb3') .checked=true"> checkbox1<br>
            >>
            >> <input type=checkbox id=cb3>checkbox 3
            >>
            >>[/color]
            >
            > <input type="checkbox"
            > onclick="docume nt.getElementBy Id('cb3').check ed=this.checked ">
            > checkbox1<br>
            >
            > <input type="checkbox" id="cb3">checkb ox3
            >[/color]

            Very nice, but not what the OP asked !!!

            --
            Evertjan.
            The Netherlands.
            (Please change the x'es to dots in my emailaddress,
            but let us keep the discussions in the newsgroup)

            Comment

            Working...