1 Replies - 1825 Views - Last Post: 06 August 2012 - 12:07 PM

#1 juni103  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 30-April 11

send table value to javascript in jsp (problem)

Posted 06 August 2012 - 12:05 PM

I want to pass tables's input tag quantity value to javascript and assign this value to the form's nquan value but it is not assigning the value.
This is the jsp code..
<div id="content">
<table id="ddReferences" cellpadding="15" style="text-align: center;" BORDER=1 CELLSPACING=1 RULES=ROWS FRAME=HSIDES>
    <tr >
    	<th>Type</th>
    	<th>Product Name</th>
    	<th>Model</th>
    	<th>Company</th>
    	<th>Price</th>
    	<th>Quantity</th>
    </tr>
    
    <% while(rst.next()){%>
    	<tr>
    		<td><%=rst.getString(1) %></td>
    		<td><%=rst.getString(2) %></td>
    		<td><%=rst.getString(3) %></td>
    		<td><%=rst.getString(4) %></td>
    		<td>Rs. <%=rst.getString(5) %></td>
    		<td><input type="text" name="quantity" value="1" size="3"></td>
    		<td><input type="button" name="add" value="Add To Cart" onclick="add(<%=rst.getInt("proID") %>, <%=rst.getInt("userID")%>)"></td>
    		
    		<td><input type="button" name="buy" value="Buy Now"></td>
    	
    	
    <%} %>
   
    </table>
    <form name="formx" method="get" action="Forward.jsp">
    	user<input type="text" name="nuser" value=""/>
		prod<input type="text" name="nprod" value=""/>
		<input type="hidden" name="nquan" value=""/>
    </form>

     	
  </div>		


javascript code is:
function add(prod, user){
	var a = prod;
	var b = user;
	document.formx.nuser.value = a;
	document.formx.nprod.value = b;
        var refTab = document.getElementById('ddReferences');
        var node = refTab.rows[1].cells[5].getElementByTagName("input")[0].getElementById("in");
        var input = node.value;
        document.formx.nquan.value = input;
	document.formx.submit();
	
}


Is This A Good Question/Topic? 0
  • +

Replies To: send table value to javascript in jsp (problem)

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10194
  • View blog
  • Posts: 37,646
  • Joined: 27-December 08

Re: send table value to javascript in jsp (problem)

Posted 06 August 2012 - 12:07 PM

We have a Java EE forum clearly labeled. Please post JSP questions there in the future. Moved to Java EE.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1