Well friends, I need some help, so here I am. I want to move the following code as a javascript function - <script type="text/javascript"> <!-- var inter_<?=$cid?> = document.getElementById('chocQnty_<?=$cid?>'); if (inter_<?=$cid?> && inter_<?=$cid?>.value) { var cqnty_<?=$cid?> = inter_<?=$cid?>.value; } else { var cqnty_<?=$cid?> = 0; } chocArray[<?=$countNo?>] = cqnty_<?=$cid?> + "~" + <?=$cprix?>; ajaxArr[<?=$countNo?>] = <?=$cid?> + "~" + cqnty_<?=$cid?>; subChoc('chocQnty_<?=$cid?>','totale_<?=$cid?>',<?=$cprix?>,chocArray,<?=$countNo?>,"",<?=$cid?>,ajaxArr); //--> </script> Code (markup): As you can see, I need mixed / combined variables here, like inter_<?=$cid?> (I have used php here, since the javascript is a part of the main page, till now). However, I want to move that to an external file, and tried doing something like - function onloadEvents(cid,countNo,cprix) { var inter_+cid = document.getElementById('chocQnty_'+cid); } Code (markup): It's not working. Wondering how can I get an equivalent of inter_<?=$cid?> in this function, where the value of $cid will come as a function argument. Any help will be appreciated. Thanks. Merry christmass to all
Hi try this code: <!-- //this is in external include file function funcName(cid,cprix,countNo){ var inter = document.getElementById('chocQnty_'+cid); if (inter && inter.value) { var cqnty = inter.value; } else { var cqnty = 0; } chocArray[countNo] = cqnty+ "~" + cprix; ajaxArr[countNo] = cid + "~" + cqnty; subChoc('chocQnty'+cid,'totale_'+cid,cprix,chocArray,countNo,"",cid,ajaxArr); } Code (markup): this is on the page replace the old code: <!-- funcName('<?=$cid?>','<?=$cprix?>',<?=$countNo?>); //--> Code (markup): Hope I didn't miss something Thanks