This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
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: 30138
    
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to submit a javascript value
 
Similar Threads
Count number of characters
How to Pass Value from struts Action class to java script
Display the Selected DropDown Value to another JSP Page
one submit button two action
problem in validating multiple radioboxes in JS