Calculator JavaScript

This is a little example about a JavaScript Calculator, he could calculate some simple things another solution is to use eval.





JavaScript code:   HTML code:

HTML select on-change event JavaScript

This is an example how to get the index and selected text from a select in html:

Try it:

Code:

JavaScript series resistor circuit calculator

This is a JavaScript calculator how calculate with the ohm's law the voltage, ampere and the resistance.Its only an example but feel free to copy change or reuse this script. Try it:










UG-U1 U2
UG-U2 U1
U1+U2 UG
RG-R1 R2
RG-R2 R1
R1+R2 RG
(UG*R1)/RG U1
(UG*R2)/RG U2
UG/RG IG
U1/R1 IG
U2/R2 IG
(R1*U2)/R2 U1
(R2*U1)/R1 U2
(R2*U1)/U2 R1
(R1*U2)/U1 R2
UG/IG RG
UG/RG IG
RG*IG UG
Code:

JavaScript parallel resistor circuit calculator

This is a JavaScript calculator how calculate with the ohm's law the voltage, ampere and the resistance.Its only an example but feel free to copy change or reuse this script. Try it:










RG=1/(1/R1+1/R2)
R1=-1/(1/R2-1/RG)
R2=-1/(1/R1-1/RG)
I1=(I2*R1)/R2
I2=(I1*R2)/R1
R1=(I1*R2)/I2
R2=(I2*R1)/I1
I2=(IG/(R1+R2))*R1
I1=(IG/(R1+R2))*R2
Code:

HTML store data in data tag

If you want to store some data in a tage you could use the data- tag. try it:

1


code:  

HTML Mail to line break

If you want to make a line break in the mail body to you could use this: its just a line feed and carriage return. For white spaces you could use this: for more information look at RFC 2368   This is a little example:   Try it: Mail to  

for loop Benchmark

This is a Perl Benchmark about the for loop with fix range and with a post increment that's the fastest increment (Perl increment Benchmark): Our result: We see that we always should choose the for loop with a fixed range its possible.

Perl increment Benchmark

This is a Perl Benchmark about post-increment,pre-increment and a normal increment: This is our result: pre increment is the fastest because it have not to increment the value and return the old value.But the fastest is the fixed range, take a look at for loop Benchmark.The default is the slowest because it have to handle other steps.

Perl array pop, push, shift, unshift

This is a notice about the array manipulation in Perl, but you should try to avoid to manipulate if you just could iterate troth the array, this is much faster, for this look at Perl shift iterate Benchmark.   pop remove and return the last element of the array. push add an element to the end of the array. shift remove and return the first element of the array. unshift add an element to the start of the array.   Code example:   Prints this:

Perl shift iterate Benchmark

This little Perl Benchmark shows that its better to iterate through an array as to manipulate via shift.For more about shift look at Perl array pop, push, shift, unshift. We see its better to iterate as to shift from an array: