RE: [SMARTY] how to get javascript to read array in smarty

"Alyssa Phan" <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <45057232A4AC6444B0F9452131E7446E0226C026@exchange.win2k.tsl.state.tx.us>
Problem solved.  Thank you very much everyone.

~alyssa

-----Original Message-----
From: pbaker [mailto:[email protected]]
Sent: Wednesday, February 15, 2006 1:39 AM
To: Alyssa Phan; [email protected]
Subject: Re: [SMARTY] how to get javascript to read array in smarty



> function mytest()
> {
>          for (j = 0; j <= customer; j++)
>          {
>                 var number1= document.getElementsByName("num1[]")[j].value;
>                 var number2 = document.getElementsByName("num2[]")[j].value;
>                 number1 = Number(number1);
>                 number2 = Number(number2);
>                 var result = number1 + number2;
>                 document.getElementsByName("total[]")[j].value = result;
>          }
> }

not tested!
try:
 <form name="test" id="test" .... >

 ....

<td>Number 1:</td><td><input type="text"
name="num[{$smarty.section.ill.index}]"
id="num[{$smarty.section.ill.index}]" /></td></tr>
<tr><td>Number 2:</td><td><input type="text"
name="num[{$smarty.section.ill.index}]" id="num[{$smarty.section.ill.index}]"/></td></tr>
<tr><td>Total:</td><td><input type="text"
name="total[{$smarty.section.ill.index}]" onBlur = "mytest()"  /></td></tr>

 ....
 ....

 and

 function mytest()
 {
          t = document.getElementById(test);
          
          for (j=0; j<=sizeof(t.num); j++)
          {
                 number1 = Number(t.num[j].value);
                 number2 = Number(t.num[j+1].value);
                 result = number1 + number2;
                 t.total[j].value = result;
          }
 }


 maybe some little modification.... and it will be work for u :)
 no tested!

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.