var val1=document.getElementById("text_1");
var but_val=document.getElementById("button_1");
var but_val2=document.getElementById("button_2");
var but_val3=document.getElementById("button_3");
function click()
{
alert("the value is " +val1.value);
}
but_val.onclick=click;
function array()
{
var length=val1.value.length;
alert("length is " +length);
var newarr=new Array();
for(var i=0;i<length;i++)
{
newarr[i]=val1.value[i];//this is the MAIN PART textbox value comes here in array supose value is 1234
alert(newarr[i]);
}
var c=0;
for(var j=0;j<length;j++)
{
//now i dont know how to to get sum of all numbers in value
}
alert("the sum is " +c);
}
but_val2.onclick=array;
piyushsol 0 Newbie Poster
Taywin 312 Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.