1

I want to post data from one page to another using javascript post method?

Below is the javascript I am using..

In test1.asp page

<script type="text/javascript">
function Service_Add(Data_ID,Data_Type)
{
var Data_ID=Data_ID;
var Data_Type=Data_Type;

document.miformulario.submit();// Here I want to pass data like "Submit(Data_ID,Data_Type)"
}
</script>

I want to post "Data_ID" and "Data_Type" to test2.asp page

2 Answers 2

3

To pass data when you submit a form, you have to include that data in a form input field (hidden, visible, doesn't matter).

Sign up to request clarification or add additional context in comments.

4 Comments

problem is test1.asp input field names are not constant
xmlHttp.open("POST","test2.asp",true); xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlHttp.setRequestHeader("Content-length", params.length); xmlHttp.setRequestHeader("Connection", "close"); xmlHttp.send(params); this is the type i using in javascript/ ajax
there is some thing like this in javascript
You aren't submitting a Javascript form. You're submitting an HTML form using Javascript (and that's the only way to do it). To send data in an HTML form, you need the data in an HTML input.
3

You can add hidden fields in your HTML form like this

<input type="hidden" id="Data_ID">
<input type="hidden" id="Data_Type">

and then set the values in your javascript function and then submit (?)

<script type="text/javascript">
function Service_Add(Data_ID,Data_Type)
{

document.getElelementByID("Data_ID").value=Data_ID;
document.getElelementByID("Data_Type").value=Data_Type;

document.miformulario.submit();

}
</script>

1 Comment

The idea was right, but the code didn't work. The way for modifying the value was the problem. It worked for me (with jQuery): $('input[name="variable"]').val(true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.