Jump to content


Photo

wrong javascript syntax but it work any explanation ?


  • Please log in to reply
4 replies to this topic

#1 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 10 October 2006 - 03:29 PM

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

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 10 October 2006 - 03:56 PM

I have no idea what you're trying to do... but use a hidden INPUT field.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 10 October 2006 - 04:11 PM

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




#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 10 October 2006 - 05:03 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 10 October 2006 - 05:09 PM

thanks you are the man




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users