onclick event fails within a form

Discussion in 'HTML' started by Greg Russell, Feb 13, 2009.

  1. Greg Russell

    Greg Russell Guest

    This seems more like an html issue than javascript, but I'm experiencing the
    failure of an onclick event when it's placed within a form, and would very
    much appreciate some insight into solving the problem, please.

    The onclick event works properly if there is no <form> structure around it,
    but within the form, it invokes the delete.php form action rather than the
    intended update.php; the checkboxes and submit button wrt delete.php work
    properly:

    <form name="multiple_delete" method="POST"
    action="delete.php?table=transactions">
    <input type="submit" name="Submit" value="Delete checked transactions">
    <table class="sortable" cellspacing="1" border="1">
    ....
    <td>
    <input type="checkbox" name="ud_id[]" value="37">
    </td>

    <td align="center" style="cursor:pointer;">
    <input type="image" src="./images/edit.png" name="update" value="37"
    onclick="location.href='./update.php?table=transactions&ud_id=37'">
    </td>
    ....
    </table>
    </form>>
    Greg Russell, Feb 13, 2009
    #1
    1. Advertising

  2. Greg Russell wrote:

    > This seems more like an html issue than javascript, but I'm
    > experiencing the failure of an onclick event when it's placed within
    > a form, and would very much appreciate some insight into solving the
    > problem, please.


    You're not posting the URL, which means that you greatly reduce the odds of
    getting useful answers, and even people's willingness to try to help. Read
    either of the groups for some time and you'll surely learn this.

    > The onclick event works properly if there is no <form> structure
    > around it, but within the form, it invokes the delete.php form action
    > rather than the intended update.php;


    Are you sure it does not do both?

    > <input type="image" src="./images/edit.png" name="update" value="37"
    > onclick="location.href='./update.php?table=transactions&ud_id=37'">


    In addition to containing invalid markup, this suggests that you're missing
    the point that <input type="image" ...> acts as kind of submit button, and
    you're not preventing it - you just _add_ some operation (when JavaScript is
    enabled).

    Followups randomized as usual.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, Feb 13, 2009
    #2
    1. Advertising

  3. Greg Russell

    Greg Russell Guest

    In news:3yjll.1605$,
    Jukka K. Korpela <> typed:

    > You're not posting the URL, which means that you greatly reduce the
    > odds of getting useful answers, and even people's willingness to try
    > to help.


    I've been posting to Usenet since 1988 and am sorry that I don't understand
    your rather snide comment; what does an in-house page-development URL have
    to do with the html issue that was clearly presented with simple,
    demonstrative code? Is it because I'm new to alt.html that you become
    initially rude while later being helpful and showing that you very clearly
    understand the issue?

    ....
    >> <input type="image" src="./images/edit.png" name="update" value="37"
    >> onclick="location.href='./update.php?table=transactions&ud_id=37'">


    > ... this suggests that you're
    > missing the point that <input type="image" ...> acts as kind of
    > submit button, and you're not preventing it - you just _add_ some
    > operation (when JavaScript is enabled).


    Thank you very much for that observation, as "<img src=...>" fixes the
    issue.

    My apologies to c.l.j. for the cross-post.
    Greg Russell, Feb 13, 2009
    #3
  4. Greg Russell wrote:

    > I've been posting to Usenet since 1988 and am sorry that I don't
    > understand your rather snide comment; what does an in-house
    > page-development URL have to do with the html issue that was clearly
    > presented with simple, demonstrative code?


    It wasn't. It seems that you failed to read HTML related groups before
    starting to post to them.

    > Is it because I'm new to
    > alt.html that you become initially rude while later being helpful and
    > showing that you very clearly understand the issue?


    You fail to understand the issue. It is common information in alt.html that
    you should post a URL and should validate your code, as your homework.
    During your 20+ years of Usenet career, didn't you ever read the advice of
    reading a group before posting to it?

    > Thank you very much for that observation, as "<img src=...>" fixes the
    > issue.


    It does not. It opens an entirely new can of worms. Hint: How did your page
    work when you tested it with JavaScript disabled?

    > My apologies to c.l.j. for the cross-post.


    Do, or don't do. Don't make fake apologies; if you know something is wrong,
    just don't do it, instead of doing it and "apologizing" it.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, Feb 13, 2009
    #4
  5. Greg Russell

    Greg Russell Guest

    In news:qykll.1659$,
    Jukka K. Korpela <> typed:

    >> Thank you very much for that observation, as "<img src=...>" fixes
    >> the issue.

    >
    > It does not. It opens an entirely new can of worms. Hint: How did
    > your page work when you tested it with JavaScript disabled?


    I have no interest whatsoever in that challenge, as this is an in-house
    web-based application with javascript enabled, hence the cross-post.
    Greg Russell, Feb 13, 2009
    #5
  6. Greg Russell

    Greg Russell Guest

    In news:qykll.1659$,
    Jukka K. Korpela <> typed:

    >> My apologies to c.l.j. for the cross-post.

    >
    > Do, or don't do. Don't make fake apologies; if you know something is
    > wrong, just don't do it, instead of doing it and "apologizing" it.


    The O.P. was cross-posted, and your followup wasn't, so my reply to you was
    apologetically cross-posted back to clj to finish the discussion there.
    Greg Russell, Feb 13, 2009
    #6
  7. Gazing into my crystal ball I observed "Greg Russell" <>
    writing in news::

    > In news:qykll.1659$,
    > Jukka K. Korpela <> typed:
    >
    >>> Thank you very much for that observation, as "<img src=...>" fixes
    >>> the issue.

    >>
    >> It does not. It opens an entirely new can of worms. Hint: How did
    >> your page work when you tested it with JavaScript disabled?

    >
    > I have no interest whatsoever in that challenge, as this is an in-

    house
    > web-based application with javascript enabled, hence the cross-post.
    >
    >


    If it is an intranet, it is better to state that when making your
    initial post. Additionally, even with Intranet, it is common to put
    something up on a public server somewhere. This is simply for the
    reason that one might not post the markup/code in a post _exactly_ as it
    is on the server.

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne Boswell, Feb 13, 2009
    #7
    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. JerryG
    Replies:
    0
    Views:
    412
    JerryG
    Dec 20, 2005
  2. bob
    Replies:
    3
    Views:
    173
  3. Randell D.
    Replies:
    7
    Views:
    149
    Dr John Stockton
    Nov 25, 2003
  4. Replies:
    2
    Views:
    239
  5. Replies:
    4
    Views:
    164
Loading...

Share This Page