开发者

how to get values from vector in JSP

开发者 https://www.devze.com 2023-01-29 06:03 出处:网络
I am developing a website in which it has searching option. after searching from database, it listed certain data in a jsp page and all the data from database are stored in vector and I am displaying

I am developing a website in which it has searching option. after searching from database, it listed certain data in a jsp page and all the data from database are stored in vector and I am displaying those data with the for each.

For each data listed in the page has one submit button. When I click button I need the particular value corressponding to the submit button. And pass it to the servlet.

I finished up to searching data and display..my problem is, I don't know how to get the value of the particular submit button and pass it to the servlet.

I need one more help sir, I have to pass the value to the javascript or to keep the value in hidden for some time.. Below I give my code so that you can understand easily .JSP coding:

Mobile form
input type="hidden" name="id_city" value="${v.city}" 
input type="submit" class="send" id="mobileid"  name="mobile" value=""  onclick="openbox('Get information by SMS/Email', 0)"/ 
 /form 
 html 
 body form action="servlet"/ 
/body 
 input type="text" name="mobile"/ 
 input type="submit" value="sendsms" 
 /form 
 /html (while giving tag its not accepting as characters dont mistake me)

openbox() is a javascript function to display a html page which is in same page with some format like the previous page has to remain and html page should appear on the previous page like a box in that it has fields textbox and submit button..

My problem is I have to take the value from the hidden value in jsp开发者_JS百科 page to the servlet after the submit button is clicked.. since the hidden value is in form if I click the submit button which is in upper html code. It reload the page so the open box is not appearing.. where i have to change the code to get the openbox window after clicking sendsms button it need to take the hiddenvalues along with the text box value to servlet. please help me..


Put each item in its own form with a hidden input element wherein you pass the item ID.

E.g.

<c:forEach items="${items}" var="item">
    <form action="view">
        <input type="hidden" name="id" value="${item.id}">
        <input type="submit" value="view">
    </form>
</c:forEach>

The item ID will be available in the servlet as follows:

Long id = Long.valueOf(request.getParameter("id"));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号