Click to See Complete Forum and Search --> : post without form fields


michelle
03-18-2003, 05:58 AM
Instead of making a function that fetches the values of the form fields in a HTML-form, I would like to "fake" an entire form, thus not having to create the actual form.

Is there some way you can create a form with javascript and post those values to a page?

<Pseudo-code>
function postFakeForm() {
var formtarget = "mypage.htm";
var formfieldName = "Michelle";

PostForm...

}

<a href="javascript:postFakeForm();">Post to the next page</a>
</Pseudo-code>

khalidali63
03-18-2003, 06:21 AM
Why go through the trouble while you'd submit the form anyway?

If your concern is that you do not want to show form elements then you can create hidden fields.

<input type="hidden" name"whatever" value="some val"/>

Cheers

Khalid

michelle
03-18-2003, 07:44 AM
The problem is that I will not know what the form-element will be. I know that I can use hidden fields, but the problem is that there can be sooo many of them, so I would prefer a solution that is a bit more dynamic.
I want to post things without having to go about the process of printing out all the hidden form fields...

// Michelle

requestcode
03-18-2003, 08:31 AM
Hi michelle,
Perhaps you could give us some more details on what you are trying to accomplish. Where is the data comming from that you need to post? Some more detail might help getting a better answer.

michelle
03-18-2003, 08:46 AM
It is kind of hard to explain it all, since it is part of a larger project, but here is an example:

I have two form fields, firstName and lastName.
Now if I post this, the values will be:
firstName="Michelle"
lastName="De Beer"

What I want is a post variable that looks like this:
Michelle="De Beer"
In PHP this is called variable variables.

Then I want to post
Michelle="De Beer"
to another page, therefor I need the simulated post and can not use any form elements allready in the page...

Hope this makes it more clear.
If not, please ask for more info.

// Michelle

khalidali63
03-18-2003, 09:10 AM
If you are using PHP or any other server side programming language,then there is no problem,you can creae form and elements dynamically,
I hope pyro sees this post soon enough..

:D

Khalid

Nevermore
03-18-2003, 02:39 PM
Are you going to want to deal with enourmous numbers of variables to submit at a time - if not, you can use GET to send the variables by contstructing a special URL dynamically. Otherwise, you will have to use POST, which is harder to use dynamically.

michelle
03-18-2003, 05:37 PM
GET has a limit, the limit of an URL (256 chars), so GET won't work...

If I want to use PHP to you create form elements dynamically, I would still need to print out hidden form-fields for everything. The dynamic creation of form elements is still not done using Javascript...

// Michelle