Custom Javascript not functioning in Wordpress -


i created custom javascript (at first) generates sum of checked fields.

however, when implement in wordpress - nothing. guess i'm overlooking something, can't seem able figure out.

this javascript:

<script type="text/javascript"> <!-- function show_selected_item_val($item) {     var res1 = 0, res2 = 0, res3 = 0, res4 = 0, res5 = 0, res6 = 0, res7 = 0, res8 = 0, res9 = 0, res10 = 0;      var res11 = 0, res12 = 0, res13 = 0, res14 = 0, res15 = 0, res16 = 0, res17 = 0, res18 = 0;      if(document.all['q1'][0].checked)        res1 = 1;     if(document.all['q2'][0].checked)        res2 = 1;     if(document.all['q3'][0].checked)        res3 = 1;     if(document.all['q4'][0].checked)        res4 = 1;     if(document.all['q5'][0].checked)        res5 = 1;     if(document.all['q6'][0].checked)        res6 = 1;     if(document.all['q7'][0].checked)        res7 = 1;     if(document.all['q8'][0].checked)        res8 = 1;     if(document.all['q9'][0].checked)        res9 = 1;     if(document.all['q10'][0].checked)     res10 = 1;     if(document.all['q11'][0].checked)     res11 = 1;     if(document.all['q12'][0].checked)     res12 = 1;     if(document.all['q13'][0].checked)     res13 = 1;     if(document.all['q14'][0].checked)     res14 = 1;     if(document.all['q15'][0].checked)     res15 = 1;     if(document.all['q16'][0].checked)     res16 = 1;     if(document.all['q17'][0].checked)     res17 = 1;     if(document.all['q18'][0].checked)     res18 = 1;      document.getelementbyid("show_content").innerhtml= res1 + res2 + res3 + res4 + res5 + res6 + res7 + res8 + res9 + res10 + res11 + res12 + res13 + res14 + res15 + res16 + res17 + res18; } //--> </script> 

this html:

<table>        <tr>        <td>           <input type="radio" name="q1" value="1" onclick="show_selected_item_val(this)"/>yes           <input type="radio" name="q1" value="0" onclick="show_selected_item_val(this)"/>no        </td>        </tr>         <tr>        <td>           <input type="radio" name="q2" value="1" onclick="show_selected_item_val(this)"/>yes           <input type="radio" name="q2" value="0" onclick="show_selected_item_val(this)"/>no        </td>        </tr>         <tr>        <td>           <input type="radio" name="q3" value="1" onclick="show_selected_item_val(this)"/>yes           <input type="radio" name="q3" value="0" onclick="show_selected_item_val(this)"/>no        </td>        </tr>         <tr>        <td>           <input type="radio" name="q4" value="1" onclick="show_selected_item_val(this)"/>yes           <input type="radio" name="q4" value="0" onclick="show_selected_item_val(this)"/>no        </td>        </tr>         ...  </table>  result is: <span id="show_content"> 

i'm loading javascript through functions.php file. checked, , load. results don't show up.

so i'm guessing handling of script not correct.

any suggestions?

try this: http://jsfiddle.net/4cfcy/

i deleted $item parameter in function , argument in function call e.g.:

function show_selected_item_val() 

...

<input type="radio" name="q2" value="1" onclick="show_selected_item_val()"/>yes <input type="radio" name="q2" value="0" onclick="show_selected_item_val()"/>no 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -