Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2: How to add button name to getURL & change color of button from data

Status
Not open for further replies.

wgardens

Programmer
Sep 7, 2004
2
US
I want to change the color of a button on a page by reading in a database entry, and also have the button call a particular URL using it's instance name as part of the URL

my starting file is at:
I'm starting to create an interactive map for a client which I want to accomplish several things. The client has a cold fusion site which allows him to enter lot numbers for sale, the price, and whether that lot has sold or not. currently the community has 341 lots - about 30 are available.
I'm planning on making each lot a button, with an instance name consisting of the lot number itself. I have a cfm page created which gives me the following output from the database:

&LotNumber=#getinfo.lotnumber#&Price=#thecost#&TotalRecords=#count.recordcount#&soldyesno=#getinfo.soldyesno#

I have the folling code attached to each button:
on (release)
{
loadVariables (" this);
}

where "248" is replaced by the actual lot number. Can I change that dynamically based on the instance name? Also, if the "getinfo.soldyesno" returns a "Yes," I want to be able to change the color of the button to red to indicate visually that it's sold.

Can anybody help?
TIA

For reference, the following script on my main timeline:

onClipEvent(load)
{
CurrentRecord = 0;
loadVariables (" this);
}
onClipEvent(data)
{
strLotPrice = Price;
strLotNumber = LotNumber;
strPosition = "Record " add String(CurrentRecord+1) add " of " add String(TotalRecords);
}
 
If you need to pass something into the CFM page and then recieve the variables that are returned from the page you will have to use loadVars.sendAndLoad().

Here's and example of how to implement it:

Code:
function sendInfo(){
	sendVars = new LoadVars();
	sendVars.lotnumber = _root.lotNumber;

	CFMresponse = new LoadVars();
	CFMresponse.onLoad = receiveReply;
	
	sendVars.sendAndLoad("[URL unfurl="true"]http://mbliving.com/WP/flash.cfm",CFMresponse,"POST");[/URL]
}

function receiveReply(result){
	if(result){
		_root.reply = CFMresponse.reply;
                //This is the reply for your yes/no value
               trace(CFMresponse.soldyesno);
	}else{
		_root.reply = "Error";
	}
}

submit.onRelease = function(){
	sendInfo();
}

That's just a sample you will have to customize it to your specifics. Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
pixl8r,

thanks, but I guess I'm not experienced enough at all to understand your code, or even where it goes. I tried placing it both on the button and on the first frame of the root movie and keep getting syntax errors.

is there anything more you can tell me about it? The .fla file is at:
 
That code is just a sample of how to successfully implement the loadVars.sendAndLoad object.

For some reason I can't open your .fla file so I can't really be any more specific. The code would go on the _root timeline on an "actions" layer. Replace the "submit" in submit.onRelease with the instance name of the button you want to start the process.

Hope that helps a bit more.



Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top