Jump to content

Archived

This topic is now archived and is closed to further replies.

isaac_cm

wrong javascript syntax but it work any explanation ?

Recommended Posts

I use dreamweaver 8.02 and I have to set the variable $_POST['
btn_addtocart_x'] to any value so when the page is post back some php code is executed so I placed the following lines in a javascript script function

this function make few checks if it succeed it submit the form and I set

the
previous variable like that

1   $_REQUEST['btn_addtocart_x'] = 1;
2   document.forms[0].submit();
3   unset($_REQUEST['btn_addtocart_x']);

the very strange thing although ffox and IE give me javascript errors to

line 1, 3 but it work fine and if I deleted these lines my php script did not

work correctly, how this is done ?

and is there any other way to Set the variable $_POST['btn_addtocart_x'] correctly and then unset the same variable after submit , I need it that way

thanks

Share this post


Link to post
Share on other sites
I have no idea what you're trying to do... but use a hidden INPUT field.

Share this post


Link to post
Share on other sites
sorry,
I set the variable $_REQUEST['btn_addtocart_x'] to "1" so my script can work also I need to unset the same variable after I submit the form from a javascirpt function
like that
    $_REQUEST['btn_addtocart_x'] = 1;
    document.forms[0].submit();
    unset($_REQUEST['btn_addtocart_x']);
please tell me what to do, thanks alot


Share this post


Link to post
Share on other sites
You're talking about JS (client-side) and PHP (server-side) in the same breath.  Set it to "1" with a hidden INPUT field, and then throw it away in your PHP script.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.