Image As Button Problem :(

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

    Image As Button Problem :(

    Hi there,

    I have a form on a contact page, and to make the layout
    cross-browser/-platform i want to use an image as a button
    instead of using an image as background on a button....

    Problem: When i insert a (e.g.) reset-button, and change the source
    type="button" to type="image", instead of resetting the form, it
    submits the form....

    Any clues?

    Thanks...

    Frizzle

  • Deniz Adrian

    #2
    Re: Image As Button Problem :(

    > Problem: When i insert a (e.g.) reset-button, and change the source[color=blue]
    > type="button" to type="image", instead of resetting the form, it
    > submits the form....[/color]

    A type="image"-input always acts as a submit.
    You can put javascript onclick to the picture.
    e.g.

    <image src="images/foo.jpg" onclick="docume nt.frm1.reset() ;">

    best regards
    deniz adrian

    Comment

    • c.anandkumar@gmail.com

      #3
      Re: Image As Button Problem :(

      you can submit the form thru javascript. sthg like <img
      src="button.gif "
      onClick="javasc ript:document.f orms['formName'].submit();">

      Comment

      • Deniz Adrian

        #4
        Re: Image As Button Problem :(

        > you can submit the form thru javascript. sthg like <img[color=blue]
        > src="button.gif "
        > onClick="javasc ript:document.f orms['formName'].submit();">[/color]

        as i understood, submitting isn't the problem, but resetting :)

        Comment

        • c.anandkumar@gmail.com

          #5
          Re: Image As Button Problem :(

          of course, you can use any of the reset() or submit() methods on your
          form. I was trying to suggest that you dont use input, instead you can
          use img as well and get through.
          Thanks
          Anand

          Comment

          • frizzle

            #6
            Re: Image As Button Problem :(

            Well, i use the same method for both buttons now,
            so thank you guys. Is this method cross-browser/platform?

            Comment

            • c.anandkumar@gmail.com

              #7
              Re: Image As Button Problem :(

              as far as i know both IE and NN has been supporting document.forms[]
              since ver 4 or around

              Comment

              • frizzle

                #8
                Re: Image As Button Problem :(

                Allrighty, thanks!

                Comment

                • J. J. Cale

                  #9
                  Re: Image As Button Problem :(


                  <c.anandkumar@g mail.com> wrote in message
                  news:1110371295 .615139.30230@f 14g2000cwb.goog legroups.com...[color=blue]
                  > you can submit the form thru javascript. sthg like <img
                  > src="button.gif "
                  > onClick="javasc ript:document.f orms['formName'].submit();">
                  >[/color]
                  IIRC not all UA versions support onclick on the image element.]
                  Jimbo


                  Comment

                  • frizzle

                    #10
                    Re: Image As Button Problem :(

                    Well, too bad guys, problem not solved:

                    Offline this works:
                    <input name="Reset" type="image" value="Reset" src="button.gif "
                    width="64" height="24">

                    Online it submits the form... Whyyyyyyyyyyyyy y :(
                    The form is in a PHP-page, but that shouldn't be the issue....

                    Please helpe me out on this one, i really want to keep the advantages
                    of a 'real' submit button instead of an image with an onClick
                    element....

                    Thanks...

                    Comment

                    • Deniz Adrian

                      #11
                      Re: Image As Button Problem :(

                      > Offline this works:[color=blue]
                      > <input name="Reset" type="image" value="Reset" src="button.gif "
                      > width="64" height="24">[/color]

                      what do you mean with "works"?
                      The upper code should submit the form, as a type="image" input in a form
                      always acts as a submit. What it never does is reset the form!
                      [color=blue]
                      >
                      > Online it submits the form... Whyyyyyyyyyyyyy y :(
                      > The form is in a PHP-page, but that shouldn't be the issue....[/color]

                      If you don't want to submit it, nore reset it, simply use <img
                      src="image.jpg" alt="image" /> :)

                      best regards
                      deniz adrian

                      Comment

                      • Evertjan.

                        #12
                        Re: Image As Button Problem :(

                        frizzle wrote on 10 mrt 2005 in comp.lang.javas cript:
                        [color=blue]
                        > Well, too bad guys, problem not solved:
                        >
                        > Offline this works:
                        > <input name="Reset" type="image" value="Reset" src="button.gif "
                        > width="64" height="24">
                        >[/color]

                        <form id='q'>
                        <input name='x'><br>
                        <img src='submitbutt on.gif'
                        onclick="docume nt.getElementBy Id('q').submit( )">
                        <img src='resetbutto n.gif'
                        onclick="docume nt.getElementBy Id('q').reset() ">
                        </form>

                        --
                        Evertjan.
                        The Netherlands.
                        (Replace all crosses with dots in my emailaddress)

                        Comment

                        • frizzle

                          #13
                          Re: Image As Button Problem :(

                          Too bad guys, problem not solved :(

                          Still want to use an image-based button. I know the following works
                          offline:
                          <input name="Reset" type="image" value="Reset" src="button.gif "
                          width="64" height="24">

                          But as soon as i put it online, instead of resetting the form, it
                          submits the form. The page the form is in, is an PHP-generated page,
                          but that shouldn't be the issue.

                          I'd really like to find a solution for this, because i want to keep
                          the advantages of a 'real' button, instead of using an image with an
                          onClick event...

                          Thanks!

                          Comment

                          • Lee

                            #14
                            Re: Image As Button Problem :(

                            frizzle said:[color=blue]
                            >
                            >Well, too bad guys, problem not solved:
                            >
                            >Offline this works:
                            ><input name="Reset" type="image" value="Reset" src="button.gif "
                            >width="64" height="24">
                            >
                            >Online it submits the form... Whyyyyyyyyyyyyy y :(
                            >The form is in a PHP-page, but that shouldn't be the issue....
                            >
                            >Please helpe me out on this one, i really want to keep the advantages
                            >of a 'real' submit button instead of an image with an onClick
                            >element....[/color]

                            An input of type image always submits the form.
                            There is no problem to solve except to find out why you want
                            to beat your head against this wall.

                            What advantages of a "real" submit button do you want to keep?

                            Comment

                            • frizzle

                              #15
                              Re: Image As Button Problem :(

                              Ok, consider my previous post unsent, i had some problems with the
                              Google Groups. Anyway, i have the problem solved, don't know why it's
                              all of a sudden working right, but it is.. :)

                              Thanks guys!

                              Comment

                              Working...