Click to See Complete Forum and Search --> : Posting Value without Form?


said_fox
08-14-2003, 01:24 PM
Hi,
Is it possible to post a variable value to another page without a form, using JavaScript?
Consider the following example:
<a href="action_page.php?anything=no" onClick="doSomthing()">Do It</a>

Now let we look at the function doSomething()

function doSomething(){
var1 = "Hello";
//????
}
What can I do, to make this function able to send or Post (with post method)
the value of var1 to the action_page.php

:confused:

brendandonhue
08-14-2003, 02:21 PM
You can't use the POST method without a form, only GET.

said_fox
08-14-2003, 03:44 PM
Ok, There's no problem with using get, but the question is How? as decripted before?

Mr J
08-14-2003, 04:27 PM
Maybe something like the following



In the calling document

<script language="JavaScript">
<!--
function doSomething(){
var1 = "Hello";
location.href = 'action_page.php?anything=no' + '?' + escape(var1);
return true;
}
//-->
</script>

<a href="#null" onClick="doSomething()">Do It</a>

In the called document (action_page.php)

<script language="JavaScript">
<!--
var dataPassed = '';
if (location.search.length > 0)
dataPassed = unescape(location.search.substring(1));
document.write(dataPassed);
//-->
</script>

said_fox
08-14-2003, 04:40 PM
Ok,
But I don't want to change any thing in the hyper link HTML Tag. I only want to add the event handler inwhich the function is going to be called.
Is this possible?