submit button with image question

Discussion in 'HTML' started by Matt, Jun 23, 2004.

  1. Matt

    Matt Guest

    In the following code, I have 2 questions regarding submit button with image.

    1) Does this code <input type="image" name="populate" src="populate.gif">
    behave the same as an HTML submit button with image populate.gif?
    When I click p1 or p2 button, it will post the page to process.asp.

    2) When I check the checkbox, I want the image in submit button change
    from populate.gif to validate.gif. Unfortunately, the code
    InputForm.p2.src = "validate.gif"; doesn't work. But
    InputForm.p1.value = "validate button"; is working for a regular HTML submit
    button.

    Any workarounds? Please advise. Thanks!!

    <html>
    <head>
    <script type="text/javascript">
    function cb_onClick()
    { if (InputForm.C1.checked == true) //NOT InputForm.C1.value == "on"
    {
    InputForm.p1.value = "validate button";
    InputForm.p2.src = "validate.gif";
    }
    else
    {
    InputForm.p1.value = "populate button";
    InputForm.p2.src = "populate.gif";
    }
    }
    </script>
    </head>
    <body>
    <form name="InputForm" method="POST" action="process.asp">
    <p><input type="checkbox" name="C1" onClick="cb_onClick()"></p>
    <p><input type="submit" name="p1" value="populate button">
    <p><input type="image" name="p2" src="populate.gif">
    </form>
    </body>
    </html>
    Matt, Jun 23, 2004
    #1
    1. Advertising

  2. Matt

    Mitja Guest

    Matt <>
    (news:) wrote:
    > In the following code, I have 2 questions regarding submit button
    > with image.
    >
    > 1) Does this code <input type="image" name="populate"
    > src="populate.gif"> behave the same as an HTML submit button with
    > image populate.gif?
    > When I click p1 or p2 button, it will post the page to process.asp.
    >
    > 2) When I check the checkbox, I want the image in submit button change
    > from populate.gif to validate.gif. Unfortunately, the code
    > InputForm.p2.src = "validate.gif"; doesn't work. But
    > InputForm.p1.value = "validate button"; is working for a regular HTML
    > submit button.
    >
    > Any workarounds? Please advise. Thanks!!


    Create two buttons (validate and populate) and show/hide them as needed.
    Make sure they're both visible at first, then hide the "redundant" one with
    JS. This way, non-JS browsers will still be able to use your site.

    > <html>
    > <head>
    > <script type="text/javascript">
    > function cb_onClick()
    > { if (InputForm.C1.checked == true) //NOT InputForm.C1.value == "on"
    > {
    > InputForm.p1.value = "validate button";
    > InputForm.p2.src = "validate.gif";
    > }
    > else
    > {
    > InputForm.p1.value = "populate button";
    > InputForm.p2.src = "populate.gif";
    > }
    > }
    > </script>
    > </head>
    > <body>
    > <form name="InputForm" method="POST" action="process.asp">
    > <p><input type="checkbox" name="C1" onClick="cb_onClick()"></p>
    > <p><input type="submit" name="p1" value="populate button">
    > <p><input type="image" name="p2" src="populate.gif">
    > </form>
    > </body>
    > </html>
    Mitja, Jun 23, 2004
    #2
    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. Russell
    Replies:
    3
    Views:
    6,898
    Lau Lei Cheong
    Jun 24, 2004
  2. Mark
    Replies:
    1
    Views:
    1,678
  3. Ghafran Abbas
    Replies:
    0
    Views:
    4,193
    Ghafran Abbas
    Oct 12, 2004
  4. James Storey via JavaKB.com
    Replies:
    7
    Views:
    11,422
  5. Replies:
    4
    Views:
    1,195
    Adrienne Boswell
    Mar 23, 2010
Loading...

Share This Page