Skip to content Skip to sidebar Skip to footer

Javascript Not Submitting Hidden Form When Clicking Text

I just asked a question similar to this but with a smaller example. However the issue with that code is not the same with my current code. (If your curious here is my previous ques

Solution 1:

When you pass a value that is a string in JavaScript you will need to quote it properly or JavaScript will think you mean a variable with that name.

e.g.

<ahref = 'javascript:getDetails(Corner2Passes)'><fontsize='6'> 2 </font></a>

should be:

<ahref="javascript:getDetails('Corner2Passes');"><fontsize='6'> 2 </font></a>

A few non-essential notes:

  • I would recommend always using the double quotes on HTML attributes for consistency/readability
  • There's no need for spaces around the = character between attribute names and values
  • The <font> tag was deprecated years ago, I'd recommend using the <span> tag instead, and although you could set the font size via a style attribute, if you add a class attribute you can style all elements you want the same way with one declaration
  • you will want to add a <!doctype html> tag before the <html> tag to ensure your pages are rendering in standards mode (much pain to come, esp. in older IE versions if you don't)
  • you don't need the lang or type attributes in your <script> tag, by default it is taken as JavaScript

Post a Comment for "Javascript Not Submitting Hidden Form When Clicking Text"