Form Input Numbers Sorted

[Total: 0    Average: 0/5]

This will order the input boxes from smallest to greatest.

Head Code:

function swap()
  var form=document.switchtext;
  var t1=form.text1; var v1=parseFloat(t1.value);
  var t2=form.text2; var v2=parseFloat(t2.value);
  if (v1 > v2)
    var temp = t1.value;
    t1.value = t2.value;

Body Code:

Please insert only numeric values.<BR />
<form name="switchtext">
<input type="text" name="text1"> <BR />
<input type="text" name="text2"> <BR />
<input type="button" name="switch" value="Switch Text" onclick=swap()>

Times Viewed: 3

Leave a Reply

Your email address will not be published. Required fields are marked *