Hi All,
I have a web page that contains a form. When the forms submit button is clicked a keyword is forwarded to a server. The server then responds by looking for the keyword (which represents a product), and if it finds the keyword it loads the page with the appropriate content. If it cannot find the keyword it responds accordingly.
The HTML which represents this form is as follows:
<form name="searchform" action="store_searchresults.asp?strCategory=&strSubCategory=&strThirdCategory" method="post" onSubmit="MM_validateForm('strKeyword','','R');return document.MM_returnValue">
<IMG SRC="../images/nav/left_nav_search.gif" WIDTH=127 HEIGHT=12 ALT="" BORDER=0>
<INPUT TYPE="HIDDEN" NAME="strAction" value="search">
<input type="text" name="strKeyword" size="11">
<input type="image" border="0" name="imageField" src="../images/nav/top_search_gob.gif" width="24" height="22"></form>
I have also used this form succesfully with static data, where I have declared a concrete value for the strKeyword variable. In the example below I declared the strKeyword value to be NBP.
<form name="searchform" action="store_searchresults.asp?strCategory=&strSubCategory=&strThirdCategory" method="post">
<input type="hidden" name="strAction" value="search">
<input type="hidden" name="strKeyword" value="NBP">
<input type="image" border="0" name="imageField" src="../images/marquee/NBP.jpg" width="85" height="63" style="filter: alpha (opacity=100); -moz-opacity: 1.0;" onMouseover="lightup(this, 40)" onMouseout="lightup(this, 100)">
</form>
The above approach also works quite well for loading a specific item (or group of items).
I am now developing a flash animation using ActionScript 3. This animation features several products that I intend to be clickable. Once clicked I hope to forward form data to the server and load a new page based on the given keyword.
I have tried the following AS code:
import fl.events.*;
import flash.events.*;
import flash.net.*;
var request:URLRequest = new URLRequest("../store/store_searchresults.asp?strCategory=&strSubCategory=&strThirdCategory");
var formVariables:URLVariables = new URLVariables();
formVariables.strAction = "search";
formVariables.strKeyword = "NBP";
request.data = formVariables;
request.method = URLRequestMethod.POST;
myButton.addEventListener(MouseEvent.CLICK, openPage);
function openPage(e:MouseEvent):void {
sendToURL(request);
}
And I have also tried the following:
import fl.events.*;
import flash.events.*;
import flash.net.*;
var request:URLRequest = new URLRequest("../store/store_searchresults.asp?strCategory=&strSubCategory=&strThirdCategory");
var formVariables:URLVariables = new URLVariables();
formVariables.strAction = "search";
formVariables.strCategory = "";
formVariables.strSubCategory = "";
formVariables.strThirdCategory = "";
formVariables.strKeyword = "NBP";
request.data = formVariables;
request.method = URLRequestMethod.POST;
myButton.addEventListener(MouseEvent.CLICK, openPage);
function openPage(e:MouseEvent):void {
sendToURL(request);
}
I am confident that both of these code fragments are sending data to the server. However I am confused regarding the nature of the forms address. I am wondering why the form uses the POST method when it clearly is appending information to the URL (as would be expected from a GET form submition method). Why does the form address contain ? marks: store_searchresults.asp?strCategory=&strSubCategory=&strThirdCategory when the POST method is being used for submittion?
Should I be explicity creating the variables strCategory, strSubCategory and strThirdCategory as I did in the second AS code section (above)? Or is the first AS code section, which does not feature these variables sufficient?
I have also come to realize that the code I have created may indeed be sending information to the server, however I want to load results into the browser page that originated the form submittion, and I do not believe that the sendToURL(request); method is suffient for this purpose.
If anybody can explain how to correctly submit data, as per my html markup, and then load the result into the browser window that contains my initial flash animation it will be greatly appreciated.
Thanks for your time.
Kind Regards
David