PDA

View Full Version : Passing form hidden vars from flash to php


red-sofa
09-27-2008, 11:01 AM
I'm placing swfs in product pages of a oscommerce site.

I trying to send the whole info of a certain product to the shopping cart.


ORIGINAL CODE IS:

<form name="cart_quantity" action="http://www.shop.com/product_info.php&action=add_product" method="post"><input type="hidden" name="products_id" value="26">
<input type="hidden" name="id[3]" value="9">


The issue is that I need to pass the two hidden vars ( products_id and id[3] - wich is atrributes of the product ( may be size, color or whatever )


I'm making my first test with 50% success.

My flash code is follow:


boton.onRelease = function(){
products_id="26";
id[3]=9;
getURL("http://www.shop.com/product_info.php?products_id=24&action=add_product", "", "POST");
}

// Possibility two /////////////////////////////

sendVars = new LoadVars();
sendVars.products_id="26";
sendVars.id[3]=9;
boton2.onRelease = function(){
sendVars.send("http://www.shop.com/product_info.php?products_id=24&action=add_product", "POST");
}


Ok, products_id does pass OK
but id[3] value doesn't pass.

May be the [3] is the problem, but I can`t change that

i MUST pass the hidden value id[3]

HELP!:o

CobaltBlueDW
09-27-2008, 05:06 PM
Attach the id[3] to the address using concatenation. e.g.

addrString = "http://someplace.com?var=1&var=2";
addrString += "&id[3]=9";

red-sofa
09-28-2008, 09:20 AM
Hi buddy

thanks for your response.

Your suggestion Dind't worked.




i made a few tests more:


tryed this:

products_id="26&id[3]=9";




tryed this:

products_id="26&id=[,,,9]";




tryed this:

products_id="26&id=(,,,9)";


tryed this:

products_id="26";
id="[,,,9]";



BUT NEVER SUCCEDDED

:(

any additional suggestion?

CobaltBlueDW
09-28-2008, 09:31 AM
If this didn't work then you'll definitely have to explain what error you are getting from it, because it should work. Percent encoding is the only thing that would keep it from working, but I doubt that's your problem.

getURL("http://www.shop.com/product_info.php?products_id=26&id[3]=9&products_id=24&action=add_product", "_top", "POST");

bowljoman
09-28-2008, 06:41 PM
You probably have to encodeURI the [].

see here for some examples on the output.
http://xkr.us/articles/javascript/encode-compare/



trace(encodeURI("id[3]"));

bowljoman
09-28-2008, 06:47 PM
id[3]=9

id%5B3%5D=9