1 Replies - 2547 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>Product Name</th>
    <% while(rst.next()){%>
    		<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>
    <%} %>
    <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=""/>


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;

Is This A Good Question/Topic? 0
  • +

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

#2 macosxnerd101  Icon User is online

  • Games, Graphs, and Auctions
  • member icon

Reputation: 11798
  • View blog
  • Posts: 44,322
  • 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