Wednesday, March 16, 2011

sorting in javascript

<html>
<head>
<script>
    function countInputs() {
        var arr=new Array();
        arr[0]=document.frm.data1.value;
        arr[1]=document.frm.data2.value;
        arr[2]=document.frm.data3.value;
        arr[3]=document.frm.data4.value;
        arr.sort();
        document.getElementById('m1').innerHTML=arr[0];
        document.getElementById('m2').innerHTML=arr[1];
        document.getElementById('m3').innerHTML=arr[2];
        document.getElementById('m4').innerHTML=arr[3];


           
    }
</script>
</head>
<body><center>
    <br><br><br><br><br><br>
<form name="frm">
    <input type="text" name="data1"/><br><br>
    <input type="text" name="data2"/><br><br>
    <input type="text" name="data3"/><br><br>
    <input type="text" name="data4"/><br><br>
    <input type="button" value="send"  onclick="countInputs()"/>
</form>
<p id="m1"></p>
<p id="m2"></p>
<p id="m3"></p>
<p id="m4"></p>
</center>
</body>
</html>

0 comments:

Post a Comment