Click here to Skip to main content
15,911,890 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have an input button inside a form, inside a table, in a row, in a cell.
It doesn't work.

I put the same button outside of thee table no problem.

Do I have to set something on the table?

Thanks,

-ren

<input type="button" value="Button" name="B3" onclick="alert('hello');"></td>
Posted
Updated 13-Mar-11 2:41am
v6
Comments
Dalek Dave 13-Mar-11 8:41am    
Edited for readability.

Nothing looks wrong nor anything extra is needed.
<input type="button" value="Button" name="B3" onclick="alert('hello');">
inside or outside a table should work and Javascript alert should be triggered.

Look in the designer if the table is correctly formed. Try to view-source the page with button in table and see if all looks good. If you are unable to, then post the viewsource (not all just the table part) for us to see.
 
Share this answer
 
Comments
Espen Harlinn 13-Mar-11 9:01am    
Reasonable - it should have worked :)
Many times there many be something that is preventing the the javascript code from executing. Well, take a look behind the scene, by utilizing the handy danady debugger. Unfortunately there is no simple or single way of debugging javascpit. Each browser has 'their' way of hooking into it. Some easy and straight forward while other, well let us leave it there.

Check FireFox's FireBug[^], Chrome's Script Debugger[^] Or IE's [don't want to go that far I hope]

You may be able to find out what it is not been called or executed.
 
Share this answer
 
Comments
Dalek Dave 13-Mar-11 8:42am    
Sage advice.
Espen Harlinn 13-Mar-11 9:05am    
It's pretty hard to debug onclick="alert('hello');" - eyeballing the html is probably what OP needs to do ... knowing how to do it is still a good thing, so my 5
Yusuf 13-Mar-11 10:15am    
I totally agree.
What I struggle many times in this forum is that, the question is not clear and well defined. So, just giving simple pointer or advice does not make justice in the face of the question.

I was tempting to elaborate more, but where do you draw the line between writing tip/trick, article or simple advice. In reality in order my advice to be meaningful, the alert() needs to be replaced with simple javascript function call and the alert() placed inside the function. That way true debugging can take place.
Espen Harlinn 13-Mar-11 10:19am    
I know - and I know *you* know, as can be easily discerned from your efforts here in the Q&A section :)
Yusuf 13-Mar-11 11:16am    
Thanks
Hello,

Thanks for the responses. It was improper formatting of the table, one of the rows was messed up.

-ren
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900