Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Thursday, April 9, 2015

HTML: POST array not showing unchecked checkbox

<td>
  <input type="checkbox" name="cb[]"/>
  <input type="checkbox" name="cb[]"/>
</td>
  • Solution 1) Explicit index + hidden trick
  • <td>
      <input type="hidden" name="cb[0]" value=""/>
      <input type="checkbox" name="cb[0]"/>
      <input type="hidden" name="cb[1]" value=""/>
      <input type="checkbox" name="cb[1]"/>
    </td>
  • Solution 2) Explicit index + fill in the blanks (e.g. with PHP)
  • <td>
      <input type="checkbox" name="cb[0]"/>
      <input type="checkbox" name="cb[1]"/>
    </td>
    $post_array = $_POST['cb'];
    $defaults = array_fill(0, 2, '0');
    $post_array = $post_array + $defaults;

Sunday, May 19, 2013

How to find id of enclosing tr

var myId = $(this).closest('tr').attr('id');

How to post without redirecting / reloading the page

$.post(action, $('#MY_FORM').serialize());

How to deal with dots in HTML id

/* "." and ":" are problematic within the context of a jQuery selector
 * because they indicate a pseudo-class and class, respectively */
myId = myId.replace(/(:|\.)/g, "\\$1");

Wednesday, January 25, 2012

SyntaxHighLighter with java and generics

In order to use SyntaxHighLighter with java code containing generics, you first need to have all < and > being replaced with &lt; and &gt;
This can be done automatically by this online HTML encoder.

Thursday, January 19, 2012

Testing your css or javascript code

  1. Go to JSFiddle.
  2. Put the HTML in the HTML area, the CSS in the CSS area, and the JavaScript in the JavaScript area
  3. Press Run and see if the result is demonstrating the problem, adjust as needed to make the problem very clear.
  4. Press Save to get a public URL.
  5. Share that URL where you are trying to get the troubleshooting help.

Tuesday, July 19, 2011

nowrap on IE

  • FF
    CSS
td { white-space:nowrap; }
  • IE:
    HTML
<td nowrap>

Including CSS for IE

<style type="text/css">
    @import url(scrolling_table.css);
</style>
<!--[if IE]>
    <style type="text/css">
        @import url(scrolling_table.ie.css);
    </style>
<![endif]-->