Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old July 14th, 2004, 02:25 AM
vikaspa vikaspa is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 99 vikaspa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 4 m 45 sec
Reputation Power: 2
Value of variable form from 2 variables

Dear All


I have a typical problem

I have am accepting qty and value and deriving amount

There are say 6 such values and I had defined the variable names as follow

qty0 rate0 amt0
qty1 rate1 amt1
qty2 rate2 amt2
qty3 rate3 amt3
qty4 rate4 amt4
qty5 rate5 amt5
qty6 rate6 amt6


I want to use for loop to derive amt
I tried by passing the counter (0,1,2,3,4 ) to a function say calcval

function calval(cntr) {
q = 'qty"+cntr+"';
r='rate"+ntr+"';
val=q * r;
}

Indeed this is not working !


Thanks in advance for help extended by you .
I really admire your efforts !

Reply With Quote
  #2  
Old July 20th, 2004, 05:33 AM
bainer bainer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 47 bainer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Value of variable form from 2 variables

It looks like you're working in Javascript (I'll show PHP code aswell).

In javascript:

Firstly, use an array for qty, rate and amt - ie. qty[0], qty[1] instead of qty0, qty1.
Code:
function calval(cntr) {
   amt[cntr] = qty[cntr] * rate[cntr];
}


In PHP:

Firstly, use an array for qty, rate and amt - ie. $qty[0], $qty[1] instead of $qty0, $qty1.
php Code:
Original - php Code
  1.  
  2. function calval($cntr) {
  3.    $amt[$cntr] = $qty[$cntr] * $rate[$cntr];
  4. }

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Value of variable form from 2 variables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT