Javascript function not working inside php code -


i trying call javascript function inside php code loop. not working. guess there wrong in line have called function. please suggest how edit code javascript function can work properly. code have tried.

<?php ?> <script>  function calculate(aa, mad, hs, gra, mas, nsm, phd, exp, intv){  document.getelementbyid(aa).value=document.getelementbyid(mad).value/10 -(-     document.getelementbyid(hs).value/10)-(-document.getelementbyid(gra).value/5)-(-document.getelementbyid(mas).value/5)-(-document.getelementbyid(nsm).value)-(-document.getelementbyid(phd).value)-(-document.getelementbyid(exp).value)-(-document.getelementbyid(intv).value); }  </script>  <?php echo " <form action='gl1p.php' method='post'>";   $noc=20;     echo "  <table align='center' border='1' style='border-collapse:collapse'    align='center'><tr> <th>sl. no</th><th>name</th><th>caste</th><th>madhyamik</th><th>hs</th>   <th>graduation</th><th>masters</th><th>net/slet/mphil</th><th>phd</th> <th>experience</th><th>interview</th><th>calculate</th><th>score</th>  </tr>";  ($i=1;$i<=$noc;++$i){    echo "<tr><td align='center'></td><td align='center' ><input type='text'   size='45' id='name{$i}' name='name[$i]'></td><td><select id='caste{$i}' name='caste[$i]'><option></option><option>ur</option><option>sc</option><option>st</option><option>obc</option></select></td><td align='center'><input type='text' size='1' id='mad{$i}' name='mad[$i]'></td><td align='center'><input    type='text' size='1' id='hs{$i}' name='hs[$i]'></td><td align='center'><input type='text' size='1' id='gra{$i}' name='gra[$i]'></td><td align='center'><input type='text' size='1' id='mas{$i}' name='mas[$i]'></td><td align='center'><input type='text' size='1' id='nsm{$i}' name='nsm[$i]'></td><td align='center'><input type='text' size='1' id='phd{$i}' name='phd[$i]'></td><td align='center'><input type='text' size='1' id='exp{$i}' name='exp[$i]'></td><td align='center'><input type='text' size='1' id='intv{$i}' name='intv[$i]'></td><td><input type=button value=calculate onclick=calculate('tot'.$i, 'mad'.$i, 'hs'.$i, 'gra'.$i, 'mas'.$i, 'nsm'.$i, 'phd'.$i, 'exp'.$i, 'intv'.$i)>";// echo "</td><td align='center'><input type='text' size='1' id='tot{$i}'  name='tot[$i]'></td></tr>"; }    echo " </table> <br/><br/><br/>  <div align='center'><input type='submit' value='prepare merit list' ></div> </form>"; ?> 

you can call

<?php   echo '     <script>       yourfunction(2,1,33);     </script>   '; ?> 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -