• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Select box Problem

 
mike mimmis
Ranch Hand
Posts: 57
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai all,

I am developing an application which uses Jsp, Servlets, Javascript and Html. while developing the application the following problem occurs. i.e

BARCODE NAME COST QUANTITY TOTAL

The above all are select boxes. when we select the barcode the Name of the product of that barcode must be displayed in Name text box . For that I use javascript Onchange function. Which works fine for First row. But After Total I have another script that creates another row of text boxes. Here the actual problem starts. when I select the barcode of Second select box The OnChange function not working .
The entire code written in Jsp.

If any Solution I am very Thankful to You
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you creating the new row? Are you attaching a new onchange handler?

Eric
 
mike mimmis
Ranch Hand
Posts: 57
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes by using onchange event i am creating multiple rows
 
Yoke Lee
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe a lil bit piece of code will be helpful.

if it were me, i would use jquery and use each() function.
 
mike mimmis
Ranch Hand
Posts: 57
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i dont have knowledge of jquery. It has to be in javascript or html or jsp
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You still have not showed code...

It is like a doctor performing surgery without the patient.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
raj legend wrote:ok i dont have knowledge of jquery. It has to be in javascript or html or jsp

jQuery is JavaScript. And it will help you do a lot of things much more easily. It is highly recommended.
 
mike mimmis
Ranch Hand
Posts: 57
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you send me logic in jqery...
 
mike mimmis
Ranch Hand
Posts: 57
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my code,



<HTML>
<HEAD>
<TITLE> Shopping </TITLE>
<SCRIPT language="javascript">
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);

newcell.innerHTML = table.rows[0].cells[i].innerHTML;

switch(newcell.childNodes[0].type) {
case "text":
newcell.childNodes[0].value = "";
break;
case "checkbox":
newcell.childNodes[0].checked = false;
break;
case "select-one":
newcell.childNodes[0].selectedIndex = 0;
break;
}
}
}

function deleteRow(tableID) {
try {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;

for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && true == chkbox.checked) {
if(rowCount <= 1) {
alert("Cannot delete all the rows.");
break;
}
table.deleteRow(i);
rowCount--;
i--;
}

}
}catch(e) {
alert(e);
}
}

</SCRIPT>
<script type="text/javascript">
function call()
{
alert("in call()");
var table = document.getElementById(tableID);

var rowCount = table.rows.length;
for(var i=0;i<colCount;i++)
{
var bc=form.brcode[i].value;
alert("value of barcode="+bc[i]);
}

}
</script>
</HEAD>
<BODY>


<form name="form" id="form" action="testExample.jsp">
<TABLE id="dataTable" width="350px" border="1">
<TR>
<TD><INPUT type="checkbox" name="chk"/></TD>
<TD><INPUT type="text" name="brcode" onchange="call();"/></TD>
<TD><INPUT type="text" name="title" /></TD>
<TD><INPUT type="text" name="cost" /></TD>
<TD><INPUT type="text" name="quantity" /></TD>

<TD><INPUT type="text" name="quantity" onchange="addRow('dataTable')" /></TD>
</TR>
</TABLE>
<INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')"/>
</form>
</BODY>
</HTML>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic