Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript function and combined variables, help appreciated

    Well friends, I need some help, so here I am. I want to move the following code as a javascript function -

    Code:
     
    <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>
    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 -
    Code:
    function onloadEvents(cid,countNo,cprix) {
       var inter_+cid = document.getElementById('chocQnty_'+cid);
    }
    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

  • #2
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    Just wanted to inform that this is solved, thanks to locdev.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •