Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > onclick event fails within a form

Reply
Thread Tools

onclick event fails within a form

 
 
Greg Russell
Guest
Posts: n/a
 
      02-13-2009
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="cursorointer;">
<input type="image" src="./images/edit.png" name="update" value="37"
onclick="location.href='./update.php?table=transactions&ud_id=37'">
</td>
....
</table>
</form>>


 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      02-13-2009
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/

 
Reply With Quote
 
 
 
 
Greg Russell
Guest
Posts: n/a
 
      02-13-2009
In news:3yjll.1605$(E-Mail Removed),
Jukka K. Korpela <(E-Mail Removed)> 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.


 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      02-13-2009
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/

 
Reply With Quote
 
Greg Russell
Guest
Posts: n/a
 
      02-13-2009
In news:qykll.1659$(E-Mail Removed),
Jukka K. Korpela <(E-Mail Removed)> 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.


 
Reply With Quote
 
Greg Russell
Guest
Posts: n/a
 
      02-13-2009
In news:qykll.1659$(E-Mail Removed),
Jukka K. Korpela <(E-Mail Removed)> 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.


 
Reply With Quote
 
Adrienne Boswell
Guest
Posts: n/a
 
      02-13-2009
Gazing into my crystal ball I observed "Greg Russell" <(E-Mail Removed)>
writing in news:(E-Mail Removed):

> In news:qykll.1659$(E-Mail Removed),
> Jukka K. Korpela <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to handle both onmouseup event and onClick event JerryG ASP .Net 0 12-20-2005 03:49 AM
Need help with onclick event to cause cursor movement into form box Matthew Javascript 2 01-21-2004 05:34 PM
Linkbutton submits the form but OnClick event does not get fired Stan ASP .Net 1 12-03-2003 03:11 AM
How to stop form submit when onClick event returns false Randell D. Javascript 4 11-27-2003 04:54 AM
js onclick event to read values from form fails - why? Randell D. Javascript 7 11-25-2003 12:19 PM



Advertisments