Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Jeanne Boyarsky
Liutauras Vilda
Sheriffs:
Tim Cooke
Bear Bibeault
paul wheaton
Saloon Keepers:
Carey Brown
Stephan van Hulst
Tim Holloway
Mikalai Zaikin
Piet Souris
Bartenders:
Forum:
HTML Pages with CSS and JavaScript
submit a form using javascript
indu iyengar
Ranch Hand
Posts: 115
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Am using spring mvc with
POST
method and when I try to submit a form using javascript function, the control is not going to controller..
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <script type="text/javascript"> function Check() { var length=document.frm.y.length; //alert(" length ::: "+length); var total=0,j=0; var str=""; for(j=0;j<length;j++) { if(document.frm.mycheckbox[j].checked) { total = parseInt(total)+parseInt(document.frm.z[j].value); str = str+document.frm.mycheckbox[j].value+" , "; //alert(" courseName ::: "+document.frm.mycheckbox[j].value+" points ::: "+document.frm.z[j].value); }//end if }//end for // alert(" selected courses ::: "+str+" \n total credits ::: "+total); if(total<60) { if(!(str.match("gk"))) { alert(" Total credits should be >= 60 and GK is compulsory subject "); window.location.reload(true); } else { alert(" Total credits should be >= 60 "); window.location.reload(true); } }//end if if(total>=60) { if(!(str.match("gk"))) { alert(" IT IS MUST TO SELECT GK "); window.location.reload(true); } }//end if else document.frm.submit(); ////////////////////// THIS SHOULD BE CALLED WHEN CONDITIONS ARE SATISFIED /////////////// }//end function </script> <style type=text/css> input.red {background-color: #cc0000; font-weight: bold; font-size: 12px; color: white;} </style> <h3><font color="green">Select the subjects so that the base marks should be > = 60 and compulsory subject is GK </font></h3> <body> <form:form name="frm" method="post" commandName="enroll"> <font color="blue"><i><b> <c:forEach items="${enroll.getValues1}" var="val"> <form:checkbox path="getValues1" id="mycheckbox" value="${val.courseName}"></form:checkbox> <c:out value="${val.courseName} ::: "></c:out> <c:out value="${val.creditPoints}"></c:out> <input type="hidden" name="y" value="${val.courseName}"></input> <input type="hidden" name="z" value="${val.creditPoints}"></input> <br></br> </c:forEach> </b></i></font> <input type="button" value="Check your Credits and ENROLL " onclick="Check()" style="background-color:#66CCCC; color:#fff"></input> ////// call to JS function </form:form> </body> </html>
please guys how to submit a form (post request) from javascript function...
thanks ,
Indu
indu iyengar
Ranch Hand
Posts: 115
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
form is resetting with document.form.submit () ...
thanks ,
Indu
Bear Bibeault
Sheriff
Posts: 67732
173
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This is an HTML forum, not a Spring forum. Showing us Spring source code is not appropriate.
Show the
relevant
portions of the HTML as they are sent to the browser.
P.S. Make sure you didn't name anything "submit".
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Yup, yup, yup. Tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Question on jQuery ajax functionality & troubleshooting called bean in JSF page
Need Help With Dynamic text box in JSP
Pressing the enter key receive extra invalid data
how to delete the rows which are checked
Retrieve data from other server using JavaScript
More...