wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes How to submit a javascript value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to submit a javascript value" Watch "How to submit a javascript value" New topic

How to submit a javascript value

deepannita singh

Joined: May 22, 2012
Posts: 1
Dear all, Please help me out!!
I am new to the javascript,
I want to submit javascript var value with html forms. Like..

<script type="text/javascript">
function form_submit(){
var count = 100;
document.myform= count; <-- Here I want to submit the "count" value. And I want to get it in the subroutine.


<form name="myform" action="[% c.uri_for('/home/updateval') %]" method="post" > <-- here "updateval" is the subroutine name in the controller.

Thanks in advance...
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30050

Welcome to CodeRanch!

You've probably noticed that document.myform= count; doesn't work. That's trying to assign a value to a form.

One approach is to create a hidden field:
<input type="hidden" name="number" />

Then you can use JavaScript to set it:
document.myform.number.value = count;

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link: http://aspose.com/file-tools
subject: How to submit a javascript value
Similar Threads
How to Pass Value from struts Action class to java script
one submit button two action
problem in validating multiple radioboxes in JS
Count number of characters
Display the Selected DropDown Value to another JSP Page