[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!
1 頁 (共 1 頁)

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!

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>

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!

Re: javascript help!

文章發表於 : 2009-02-03 11:27
chinhsi
var numbers = new array (5)
numbers [0]=document.autoSumForm.c[1].value
...
for ( var i = 0; i < numbers.length; i++)
{
}

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

Re: javascript help!

文章發表於 : 2009-02-03 11:59
chinhsi
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

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

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 :)

Re: javascript help!

文章發表於 : 2009-02-03 12:20
chinhsi
document.autoSumForm.cs.value =numbers.prototype.sum
我猜的,我沒跑
不行就再討論囉

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 :(