File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

How to submit a javascript value

deepannita singh
Greenhorn

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.
document.myform.submit();

}

</script>
<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
Marshal

Joined: May 26, 2003
Posts: 30369
    
150

Deepannita,
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to submit a javascript value