[Javascript] check value on the fly input tag

andy susanto andy78 at centrin.net.id
Wed Sep 17 18:54:46 CDT 2003


hai,

 i am try to check a value on the fly input tag, can anyone help to solve my
problem ?

this is my code :

<HTML>
<HEAD>
<STYLE>
      #contentpage {color:#000000; font-size:11pt; width:388};
</STYLE>
<SCRIPT>
i=0;
w="";
function createobj(isi){
  w += isi;
  document.all['test'].innerHTML = "<table><tr><td>Kode
</td><td>Description</td><td>Jumlah</td></tr>"+w+
   "<tr><td><Input type='button' ONCLICK='lagi()'></td></tr></TABLE>";
}

function lagi(){
  isi = "<tr><td><INPUT Type='checkbox' Name='cek'+i Value=1 CHECKED><INPUT
TYpe='text' Name='kd'+i VALUE=''></td>"+
   "<td><INPUT TYpe='text' Name='des'+i VALUE=''></td>"+
   "<td><INPUT TYpe='text'Name='jml'+i
ONBLUR=alertvalue('jml',eval('document.forms[0].jml'+i+'value'))
VALUE=''></td></tr>";
  createobj(isi);
  i++;

}


function alertvalue(obj,idx){
  kode = 'kd'+idx;
  jumlah = 'jml'+idx;
alert(obj);
  alert(idx);
  if (obj=='jml'){
    if (jumlah.value == 'undefined'){
      alert('Hai Your Value is 2');
      lagi();
    }
    else{
       alert('Hai Your Value is not 2');

    }
  }
}

</SCRIPT>
</HEAD>
<Body onload= 'createobj("");'>

<Form Name='tt'>
<TABLE><TR>
<TD ID='test'></TD></TR>
</TABLE>
</FORM>

</Body>
</HTML>




More information about the Javascript mailing list