php - Insert a variable in javascript -


weel, i'm creating cicle javascript , php.

this php

while  (($num_images > 0) && ($num_images < 5))         {              echo '<a href="javascript: submitform' . $num_images . '()"><img id="myimgid" class="nomarge" alt="" src="image' . $num_images . '.jpeg" width="' . $ver  . '" height="' . $hor . '"/></a>';              echo $num_images;              $num_images--;         } 

and now, want javascript like:

<script type="text/javascript">  var img = 4; (img = 4, img > 0, img--) {     function submitform() {document.myform.submit();} } </script> 

well... how make submitform1() myform1 ....

instead of making new functions submit each form, make single function, submitform(), pass form index parameter (e.g. i parameter).

like this, need write 1 function , function, submitform(i) submit corresponding form.

you make follows:

   function submitform(i){         document.forms[i].submit()     } 

and php:

   echo '<a href="javascript: submitform(' . $num_images . ')"><img id="myimgid" class="nomarge" alt="" src="image' . $num_images . '.jpeg" width="' . $ver  . '" height="' . $hor . '"/></a>'; 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -