[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4612: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4614: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4615: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4616: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
富 貴 山 莊 討 論 區 | 網 賺 • 檢視主題 - javascript help!

javascript help!

javascript help!

文章陶 朱 公 » 2009-02-02 17:59

<script type="text/javascript">
function sayHey() {

fo.e4.value=fo.e1.value+fo.e2.value+fo.e3.value;
}
</script>
<FORM name=fo>
<input type=text name=el onchange="sayHey()"><br>
<input type=text name=e2 onchange="sayHey()"><br>
<input type=text name=e3 onchange="sayHey()"><br>
<input type=text name=e4>
</FORM>
I want e4 will show the sum of e1 and e2 after enter to it.
The current one is not working!

Also, i want to change them to array that it will sum up no of field and show in the last field, thank you!
Thank you!
本 站 host - []
頭像
陶 朱 公
莊 主
 
文章: 3095
註冊時間: 2003-08-30 18:14

Re: javascript help!

文章陶 朱 公 » 2009-02-02 18:04

Solved, thanks for 哥斯拉

http://webforumz.com/javascript-forum/6 ... th-sum.htm

<script type="text/javascript">
function startCalc(){
interval = setInterval("calc()",1);
}
function calc(){
one = document.autoSumForm.c1.value;
two = document.autoSumForm.c2.value;
document.autoSumForm.thirdBox.value = (one * 1) + (two * 1) ;

}
function stopCalc(){
clearInterval(interval);
}
</script>
<form name="autoSumForm">

<p>
1<input class="right" type=text name="c1" value="" onFocus="startCalc();" onBlur="stopCalc();">
<br>

2<input class="right" type=text name="c2" value="" onFocus="startCalc();" onBlur="stopCalc();">
<br>

3<input class="right" size="5" maxlength="5" type=text name="thirdBox">
</p>
</form>
頭像
陶 朱 公
莊 主
 
文章: 3095
註冊時間: 2003-08-30 18:14

Re: javascript help!

文章陶 朱 公 » 2009-02-02 20:44

Problem again
how to convert them in array ?

<script type="text/javascript">
function startCalc(){
interval = setInterval("calc()",1);
}
function calc(){
d1= document.autoSumForm.c[1].value;
d2= document.autoSumForm.c[2].value;
d3= document.autoSumForm.c[3].value;
d4= document.autoSumForm.c[4].value;
d5= document.autoSumForm.c[5].value;
d6= document.autoSumForm.c[6].value;
document.autoSumForm.cs.value = ((d1 * 1)+(d2 * 1)+(d3 * 1)+(d4 * 1)+(d5 * 1)+(d6 * 1))*2 ;
document.autoSumForm.cs1.value = "-" ;

}
function stopCalc(){
clearInterval(interval);
}
</script>




<input type="text" name="c[1]" onFocus="startCalc();" onBlur="stopCalc();" size=3>
<input type="text" name="c[2]" onFocus="startCalc();" onBlur="stopCalc();" size=3>
<input type="text" name="c[3]" onFocus="startCalc();" onBlur="stopCalc();" size=3>
...

how to use arrary in javascript ?

thank you!
頭像
陶 朱 公
莊 主
 
文章: 3095
註冊時間: 2003-08-30 18:14

Re: javascript help!

文章chinhsi » 2009-02-03 11:27

EasyHits4U
看1000網頁賺0.3美元
3美元領款
var numbers = new array (5)
numbers [0]=document.autoSumForm.c[1].value
...
for ( var i = 0; i < numbers.length; i++)
{
}
chinhsi
 
文章: 27
註冊時間: 2008-11-17 5:15

Re: javascript help!

文章陶 朱 公 » 2009-02-03 11:44

cool;

numbers [0]=document.autoSumForm.c[1].value
should it be
numbers [1]=document.autoSumForm.c[1].value ?

or any method that can set the whole array ?
number=c

thank you very much
頭像
陶 朱 公
莊 主
 
文章: 3095
註冊時間: 2003-08-30 18:14

Re: javascript help!

文章chinhsi » 2009-02-03 11:59

make money with your web site
100美元一個有效下線,
也真是收到錢!

arrat總是從0開始
array好像只有這種方式設定(這是你的問題嗎?)
如果你有很多變數
就寫個for下去跑,然後加到array
for ( var i = 0; i < numbers.length; i++)
{
numbers [0]=document.autoSumForm.c[i+1].value
}

你如果要知道array裡面數字的總合
也是用for 跑,常用的話就寫成function
Array.prototype.sum = function(){
for(var i=0,sum=0;i<this.length;sum+=this[i++]);
return sum;
}

http://snippets.dzone.com/posts/show/769
chinhsi
 
文章: 27
註冊時間: 2008-11-17 5:15

Re: javascript help!

文章陶 朱 公 » 2009-02-03 12:16

Array.prototype.sum = function(){
for(var i=0,sum=0;i<this.length;sum+=this[i++]);
return sum;
}

Is it i can set

document.autoSumForm.cs.value =Array.prototype.sum ??

Thank you
頭像
陶 朱 公
莊 主
 
文章: 3095
註冊時間: 2003-08-30 18:14

Re: javascript help!

文章陶 朱 公 » 2009-02-03 12:18

OR

document.autoSumForm.cs.value =numbers.sum


Becuase i am not at home, so cannot test with web page now

you are so helpful :)
頭像
陶 朱 公
莊 主
 
文章: 3095
註冊時間: 2003-08-30 18:14

Re: javascript help!

文章chinhsi » 2009-02-03 12:20

document.autoSumForm.cs.value =numbers.prototype.sum
我猜的,我沒跑
不行就再討論囉
chinhsi
 
文章: 27
註冊時間: 2008-11-17 5:15

Re: javascript help!

文章陶 朱 公 » 2009-02-03 20:08

thank you very much...

i decide to give up ..

as just a 花巧 display

use up too many time and energy ...


But ...thanks a lot :)

Do not know why , i am ok with php by not ok with flash and javascript :(
頭像
陶 朱 公
莊 主
 
文章: 3095
註冊時間: 2003-08-30 18:14


回到 網 頁 討 論 & phpBB3 使 用 心 得 & 電 腦 軟 硬

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客

cron