Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy do php form arrays behave strangely/(unexpectedly) in jQuery
    primarykey
    data
    text
    <p>Why do php form input arrays act funny in jQuery?</p> <p>Is there any way to overcome this?</p> <p>Hi, I wrote this code and it works.. Updating a form of 21 radio inputs to <em>emphasize</em> the label next to the checked radio(s).</p> <p>*visually - not as in the a html tag </p> <pre><code>$(function() { for(count = 0;count&lt;21;count++) { result = $("input:radio[name=choice"+count+"]:checked").val(); $("input[name=\"choice"+count+"\"][ value=\""+ result +"\"]").attr("class", "magic"); $("div.radio:has(input.magic)").attr("class", "radio spell"); } $("input").click(function() { $("div.radio:has(input.magic)").attr("class", "radio"); $("input.magic").removeAttr("class", "magic"); var count = 0; var result = 0; for(count = 0;count&lt;21;count++) { result = $("input:radio[name=choice"+count+"]:checked").val(); $("input[name=\"choice"+count+"\"][ value=\""+ result +"\"]").attr("class", "magic"); $("div.radio:has(input.magic)").attr("class", "radio spell"); } }); }); </code></pre> <p>Here is the css</p> <pre><code>input[type="radio"] { height: 20px; } input[type="radio"] + label { color: #777; font-weight:100; letter-spacing: 1px; } input[type="radio"].magic + label { color: black; font-style: italic; /*text-decoration:underline;*/ font-weight: 600; letter-spacing: 0px; text-align: center; display:inline-block; width: 80px; } div.radio.spell { border: outset white 2px; } </code></pre> <p>Now the radio names used are choice0 - choice20 And it works ok.</p> <p>Before that I used choice[0] - choice[20] And it did not work at all. It behaved very weird.</p> <p>The jQuery code was something like: result = $("input:radio[name=choice["+count+"]]:checked").val(); ...</p> <p>I am wondering, is there anyway around that?</p> <p>Thank you for any valuable input.</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.
 

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