java - 如何将jsp页面中显示的列表值传递到java中的javascript方法中

标签 java javascript jquery html jsp

<%@ta glib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 

<pre>Bin</pre>
<pre>UPC Code</pre>
<pre>Total Tickets</pre>
<pre>Balance</pre>
<pre>Value</pre>
<pre>Tickets Sold</pre>
<pre>Total</pre>
<pre>End of Life</pre>

<c:forEach items="${scratchlistlotto }" var="sl">
   <input name="scratchid" type="hidden"    id="scratchid"  value="${sl.scratchid }" />             
   <input name="binid" type="text"  class="table_color1" id="binid"   value="${sl.bin }" /> 
   <input name="upccode" type="text"   id="upccode"   value="${sl.upccode }" /></td>

   <input name="totalticketss" type="text"   id="totalticketss"   value="${sl.totaltickets }"/>
   <input name="openingbalance" type="text" id="openingbalance" value="${sl.closingbalance }" />
   <input name="closingbalnce" type="text" id="closingbalnce" onchange="javascript:Total(this.value)"    />    

   <input name="value" type="text"   id="value"   size="6" value="${sl.values }" /> 
   <input name="ticketssold" type="text"   id="ticketssold"   /> 
   <input name="total" type="text"   id="total"   />
   <input type="text" name="hidden" value="${sl.i }"/>
   <input name="endoflife" type="checkbox" class="text_border" id="endoflife"    /></td>

</c:forEach>

JS

function Total(v) { 
    var closingbalnce = parse Float(v);         
    var openingbalance = document.getElementById["openingbalance"].value;        
    var ob = document.getElementById["closingbalnce"].value;

    alert("hiiii "+ob);        
    alert("closingbalnce "+openingbalance); 

    var totalscratchtotal = parseFloat(document.name.totalscratchtotal.value);        
    var ts = closingbalnce-openingbalance;         
    document.name.ticketssold.value = ts;         
    var value = parseFloat(document.name.value.value);        
    document.name.total.value = ts  *value;          
    document.name.totalscratchtotal.value = totalscratchtotal + (ts * value);
}

我使用jSTL标签在jsp页面中显示我的列表值,我的数组列表是(scratchliSTLotto),当我将期末余额放入>文本框时,请帮助我,我想将期初余额发送到java脚本方法中

最佳答案

您可以像这样将列表中的值传递给 js 方法

<script>Total('${sl.closingbalance }')</script>

关于java - 如何将jsp页面中显示的列表值传递到java中的javascript方法中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22855661/

相关文章:

java - Solr 5.1 : Solr is creating way too many log files

javascript - 在react+react-router-dom中将函数引用传递给sibling-ish

javascript - rails 4 : Unpermitted parameter

带有 HTML 下拉菜单的 jQuery

java - 打印非常大的 BigIntegers

java - 在 Web 应用程序中重定向或转发

Javascript 全局(主体)点击事件注册在 Safari 中不起作用

jquery - Firefox 不接受元素上的 CSS 类

javascript - 当我加载页面时 jQuery 不工作

java - 如何将Android字符串数组加载到ListView中?