Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just had to deal with IE6's wonderful implementation of <code>button</code> elements. This solution <em>does</em> rely on Javascript but some may find it useful.</p> <p>It's particularly annoying when using the AbstractWizardController in the Spring framework as the <code>button</code> element is the ideal solution for the "Next", "Back" and "Finish" buttons of the wizard but don't work in IE6.</p> <p>So, I ended up writing a small jQuery based fix (though it's quite trivial to convert it so that you don't have to use the jQuery library).</p> <pre><code>$(function(){ if((window.XMLHttpRequest == undefined) &amp;&amp; (ActiveXObject != undefined)) { $('button').click( function(event) { var rx = /\bvalue ?= ?(".*?"|'.*?')/i; var matches = $(this)[0].outerHTML.match( rx ); if( matches != null ) $(this).attr( 'value', matches[1].substring( 1, matches[1].length - 1 ) ); $('button').not( $(this) ).attr('disabled','disabled'); }); } }); </code></pre> <p>This will add an onclick event to all button elements. When a button is clicked it will grab the outerHTML of the button, e.g.:</p> <pre><code>&lt;button name="playerId" value="34"&gt;Walter Payton&lt;/button&gt; </code></pre> <p>and parse out the value attribute. Seems a lot of trouble to go in order to get the value but I found that <code>getAttributeNode('value').value</code> returned the innerHTML rather than the specified value attribute so wasn't very helpful. We then set the submatch of the regex as the value of the button. It should match it if you use either double or single quotes as delimiters but <em>you do have to use some form of delimiter</em>.</p> <p>The upshot of this is that instead of "Walter Payton" being posted it will actually post "34" instead. The downside is that the button's appearance on the page will also change to "34" just before the form is submitted.</p> <p>Finally the script will find all button elements except the clicked one and set their <code>disabled</code> attribute to be disabled. This ensures they aren't included in the POST and you don't get false positives.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload