---
title: "Send javascript function variable with form"  
description: "Send javascript function variable with form"  
author: "Samuel Fernandes"  
published: 2013-03-12  
updated: 2013-03-12  
canonical: https://www.mindstick.com/forum/655/send-javascript-function-variable-with-form  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# Send javascript function variable with form

Hi Everyone!

I need to send a [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation) returned from a [JavaScript function](https://www.mindstick.com/forum/2090/send-data-from-asp-dot-net-code-behind-to-a-javascript-function) with a [form](https://www.mindstick.com/forum/6/multi-form-mfc-application).

<form [name](https://yourviews.mindstick.com/view/87450/how-to-generate-a-brand-name-using-linkedin-comprehensive-guide)="RegForm" [method](https://www.mindstick.com/forum/166/webservice-method)="[post](https://www.mindstick.com/articles/12829/aspects-that-make-australia-post-shipping-extension-a-useful-tool)" [action](https://www.mindstick.com/forum/155752/what-is-action-result-with-its-types)="/validate_accountinfo.php" onsubmit="send()">\
</form>

\
function send()\
{\
var number = 5;\
return number;\
}\
In the validate_accountinfo.php I want to return the [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) of the function. How to do this?

Thanks for advance.

## Replies

### Reply by AVADHESH PATEL

Hi Samuel!

Add an <input hidden id="thevalue" name="thevalue" /> to the form, set its value using [JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) and then submit the form.

<form id="RegForm" name="RegForm" method="post" action="/validate_accountinfo.php" onsubmit="send()">\
<input hidden id="thevalue" name="thevalue" />\
</form>

<script type="text/javascript">\
[function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) send()\
{\
var number = 5;\
return number;\
}\
document.getElementById('thevalue').value = send();\
document.getElementById('RegForm').submit();\
</script>


---

Original Source: https://www.mindstick.com/forum/655/send-javascript-function-variable-with-form

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
