onclick event fails within a form

G

Greg Russell

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>>
 
J

Jukka K. Korpela

Greg said:
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.
 
G

Greg Russell

In
Jukka K. Korpela said:
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?

....
... 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.
 
J

Jukka K. Korpela

Greg said:
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.
 
G

Greg Russell

In
Jukka K. Korpela said:
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.
 
G

Greg Russell

In
Jukka K. Korpela said:
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.
 
A

Adrienne Boswell

In

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top