Hi,

----- Original Message ----- 
From: "brent simpson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 2001. május 13. 11:08
Subject: [PHP] passing variables without form submit


> 
> I'm trying to write what I thought would be a pretty simple script 
> action to pass a variable from a form element without a sumbit button to 
> subsequent pages; instead of a form button i would like any number of
> links to other pages to be able to pass this checkbox value: ie whether
> it is checked or not.

You 're thinking of something like this, aren't you?
<A href="javascript:document.forms[0].submit();"> ... </A>

> 
> Doesn't seem as easy as I thought. I tried using some crazy JavaScript / 
> PHP thing whereby an onChange in the form element submitted the form to 
> itself, hoping perhaps nievely that the php in the links to pages i want 
> to recieve this variable would pick it up:
> 
> ie: <A href="this.html?source=<?php echo $value;?>">this page</a>
> 
> where value would be whether the checkbox was checked or not, but no go.

You should notice that PHP is running on the server and all variable references are 
resolved on the server side before it releases the HTML content.

I think what you need is some Javascript:
<A href="javascript:go_where_my_variable_says('this.php');">this page</a>

<SCRIPT LANGUAGE="JavaScript">
<!--
function go_where_my_variable_says(where)
{
    document.forms[0].action = where;
    /* here you can manipulate your variables on the client side, before submit the 
form, 
        ie. clear input box named 'input1' :
        document.forms[0].input1 = ''; */
    document.forms[0].submit();
}
//-->
</SCRIPT>

> Then I tried using Javascript to do the same onChange thing but set a 
> cookie, that could be read by subsequent pages through php, but no luck 
> there. Can someone tell me where i'm going wrong in my thinking about this?
> 
> brent.
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to