madkixt 0 Unverified User

Hello all ... Greetings

I'm learning the basic javascript, I tried to combine between conventional javascript and Jquery framework but I have a little problem ...

this my function addRow

function addRow(tableID) {

            var table = document.getElementById(tableID);

            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);

            var colCount = table.rows[0].cells.length;

            for(var i=0; i < colCount; i++) {

                var newcell    = row.insertCell(i);
                var idPrefix='cell'

                newcell.innerHTML = table.rows[0].cells[i].innerHTML;
                //alert(newcell.childNodes);
				newId=idPrefix+rowCount+'_'+i;
                newcell.childNodes[0].id=newId; //new id untuk setiap new cell  generated
                if(i==0) {newcell.innerHTML=rowCount+1+'.'; }
                if(i==2) { 
				newcell.innerHTML+="<span id='AddIcon'><a href=\"javascript:void(0)\" onclick=\"openWindow('"+idPrefix+rowCount+"')\">+</a></span>"; 
				} 
                
				if (i >= 1 && document.getElementById('IconAdd').style.visibility == 'visible') {
					document.getElementById('IconAdd').style.visibility='hidden';
				}
				
               switch(newcell.childNodes[0].type) {
                    case "text":
                            newcell.childNodes[0].value = "";
                            break;
                }
				
            }
        }

and this my AutoSuggest Jquery Code

function namaVal(inputString){
	if(inputString.length == 0) {
			$('#pass').fadeOut();
		} else {
		$('#name').addClass('load');
			$.post("testb.php", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#pass').fadeIn();
					$('#passList').html(data);
					$('#name').removeClass('load');
				}
			});
		}
	}

function namaFill(thisValue) {
	  $('#name').val(thisValue);
	  setTimeout("$('#pass').fadeOut();", 600);
}

this my HTML form

<form name="testa" action="" method="post">
<table cellpadding="0" cellspacing="0" border="1">
        <thead>
            <tr>
               	<th>No.</th>
                <th>A </th>
                <th>B </th>
             </tr>
        </thead>
        <tbody id="dataTable">
            <tr>
   	        	<td>1.</td>
                <td>
                <div id="box">
                <input type="text" name="nama" onkeyup="namaVal(this.value);" onblur="namaFill();" id="cell0_1" />
                <div class="suggestionsBox" id="pass" style="display: none;"> 
        			<div class="suggestionList" id="passList"> &nbsp; </div>
	  			</div>
                </div>
                </td>
                <td><input type="text" name="test" readonly="readonly" id="cell0" />&nbsp;&nbsp;<span id="IconAdd" style="visibility:visible"><a href="javascript:void(0)" onclick="openWindow('cell0')"><b>+</b></a></span></td>
                </tr>
        </tbody>
</table>      
</form>
<br /><br />
<input type="button" value="Add More &raquo;" onclick="addRow('dataTable')" />

so if I add row and i find on row 2 column A, definite value to the Row 1 Column A not in Row 2 Column B

please help me how i can solve this problem... thanks... :)

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.