Display button when checkbox checked?

Discussion in 'Javascript' started by Targa, Jan 6, 2004.

  1. Targa

    Targa Guest

    I have a form in which I want to have an button(image) displayed next to a
    checkbox when it is checked.
    If the box is unchecked, the button should disappear.

    How can I do this?

    Thanks!
     
    Targa, Jan 6, 2004
    #1
    1. Advertising

  2. Targa

    McKirahan Guest

    "Targa" <> wrote in message
    news:AHrKb.58$...
    > I have a form in which I want to have an button(image) displayed next to a
    > checkbox when it is checked.
    > If the box is unchecked, the button should disappear.
    >
    > How can I do this?
    >
    > Thanks!



    Perhaps?


    <html>
    <head>
    <title>button.htm</title>
    <script language="javascript" type="text/javascript">
    <!--
    function checker(that) {
    if (that.checked) {
    toggle.style.display = "";
    } else {
    toggle.style.display = "none";
    }
    }
    // -->
    </script>
    </head>
    <body>
    <form>
    <input type="checkbox" name="Box" onclick="checker(this)">
    <span id="toggle" style="display:none">
    <input type="button" value="Button">
    </span>
    </form>
    </body>
    </html>
     
    McKirahan, Jan 6, 2004
    #2
    1. Advertising

  3. Targa

    Targa Guest

    Hey - This works great!

    However, I have several fields below the initial checkbox and button. Anyway
    to leave those alone?

    Thanks!

    "McKirahan" <> wrote in message
    news:AOsKb.234567$8y1.1054172@attbi_s52...
    > "Targa" <> wrote in message
    > news:AHrKb.58$...
    > > I have a form in which I want to have an button(image) displayed next to

    a
    > > checkbox when it is checked.
    > > If the box is unchecked, the button should disappear.
    > >
    > > How can I do this?
    > >
    > > Thanks!

    >
    >
    > Perhaps?
    >
    >
    > <html>
    > <head>
    > <title>button.htm</title>
    > <script language="javascript" type="text/javascript">
    > <!--
    > function checker(that) {
    > if (that.checked) {
    > toggle.style.display = "";
    > } else {
    > toggle.style.display = "none";
    > }
    > }
    > // -->
    > </script>
    > </head>
    > <body>
    > <form>
    > <input type="checkbox" name="Box" onclick="checker(this)">
    > <span id="toggle" style="display:none">
    > <input type="button" value="Button">
    > </span>
    > </form>
    > </body>
    > </html>
    >
    >
     
    Targa, Jan 6, 2004
    #3
  4. Targa

    McKirahan Guest

    "Targa" <> wrote in message
    news:ketKb.72$...
    > Hey - This works great!
    >
    > However, I have several fields below the initial checkbox and button.

    Anyway
    > to leave those alone?
    >
    > Thanks!


    Just put
    onclick="checker(this)"
    on the checkbox(es) you want.

    Or are you asking about the movement of those items when the button appears?
    If so, then try:

    <html>
    <head>
    <title>buttton.htm</title>
    <script language="javascript" type="text/javascript">
    <!--
    function checker(that) {
    if (that.checked) {
    toggle.style.visibility = "visible";
    } else {
    toggle.style.visibility = "hidden";
    }
    }
    // -->
    </script>
    </head>
    <body>
    <form>
    <input type="checkbox" name="Box" onclick="checker(this)">
    <span id="toggle" style="visibility:hidden">
    <input type="button" value="Button">
    </span>
    <br><input type="checkbox" name="Box" onclick="checker(this)">
    </form>
    </body>
    </html>
     
    McKirahan, Jan 6, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthew Louden

    checkbox checked change event question

    Matthew Louden, Nov 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    5,409
    Teemu Keiski
    Nov 18, 2003
  2. RodBillett

    Always One checkbox checked

    RodBillett, Dec 4, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    1,268
    bruce barker
    Dec 4, 2003
  3. yurps
    Replies:
    1
    Views:
    6,932
    rajeshthangarasu1983
    Feb 29, 2008
  4. runescience
    Replies:
    0
    Views:
    4,291
    runescience
    Feb 23, 2006
  5. randy
    Replies:
    13
    Views:
    461
    Tad McClellan
    Nov 1, 2003
Loading...

Share This Page