File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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
author & internet detective

Joined: May 26, 2003
Posts: 33119

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;

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: How to submit a javascript value
It's not a secret anymore!