azz
07-22-2003, 03:50 AM
Hey all!
OK, here's an interesting question.
I have been using an array of javacript object to control various things on my site from image placements to include files. Here's a quick sample so you know what I'm talking about:
function showId() { Response.Write(this.id); }
function showId() { Response.Write(this.id); }
function showInclude() { Response.Write(this.include); }
function showText(){ Response.Write(this.text); }
function PageObject(id, include, text)
{ this.id = id;
this.include = include;
this.text = text;
this.showId = showId;
this.showInclude = showInclude;
this.showText = showText; }
var PageArray = new Array();
PageArray[0] = new PageObject("flights","/uk/travel/_include/flightshop.asp","Flights");
PageArray[1] = new PageObject("tours","/uk/travel/_include/tourshop.asp","Tours");
PageArray[2] = new PageObject("coach","/uk/travel/_include/coachshop.asp","Coach Tickets");
PageArray[3] = new PageObject("hotels","/uk/travel/_include/hotelshop.asp","Hotels");
PageArray[4] = new PageObject("hostels","/uk/travel/_include/hostelshop.asp","Hostels");
PageArray[5] = new PageObject("insurance","/uk/travel/_include/insuranceshop.asp","Travel Insurance");
PageArray[6] = new PageObject("shipping","/uk/travel/_include/shippingshop.asp","Shipping");
PageArray[7] = new PageObject("calls","/uk/travel/_include/callshop.asp","Cheap Calls");
PageArray[8] = new PageObject("deals","/uk/travel/_include/dealshop.asp","Late Deals");
PageArray[9] = new PageObject("gifts","/uk/travel/_include/giftshop.asp","Gifts");
PageArray[10] = new PageObject("activities","/uk/travel/_include/leisureshop.asp","Leisure Activities");
PageArray[11] = new PageObject("visas","/uk/travel/_include/visainfo.asp","Visa Information");
PageArray[12] = new PageObject("guides","/uk/travel/countryguides/content_countryguides.inc","Country Guides");
Right. So far so good. Now onto my question. I want to write a script that will control the display of recruitment agencies. These agency objects will have properties like link, imageURL, displayText etc. However, each agency wil have a industryCategory property, but each agency deals with more than one industry sector. Is there any way I can define an array of categories for each potential object and use that array as a property. ie something like this:
AgentArray[0] = new AgentObject("text","link","image",...,"category[0]");
AgentArray[1] = new AgentObject("text","link","image",...,"category[1]");
etc
The only problem with this is that I'm not at all sure how I would define the object. All very well saying:
function AgencyObject(text, link, image, category)
{ this.text = text;
this.link = link;
this.image = image;
this.category = category; }
but how do I modify the category property definition so that the object knows that it's expecting an array? Any hints on how I would iterate through this other array using the object would be great too!
any ideas, oh developer.com gurus?
cheers, people
azz
OK, here's an interesting question.
I have been using an array of javacript object to control various things on my site from image placements to include files. Here's a quick sample so you know what I'm talking about:
function showId() { Response.Write(this.id); }
function showId() { Response.Write(this.id); }
function showInclude() { Response.Write(this.include); }
function showText(){ Response.Write(this.text); }
function PageObject(id, include, text)
{ this.id = id;
this.include = include;
this.text = text;
this.showId = showId;
this.showInclude = showInclude;
this.showText = showText; }
var PageArray = new Array();
PageArray[0] = new PageObject("flights","/uk/travel/_include/flightshop.asp","Flights");
PageArray[1] = new PageObject("tours","/uk/travel/_include/tourshop.asp","Tours");
PageArray[2] = new PageObject("coach","/uk/travel/_include/coachshop.asp","Coach Tickets");
PageArray[3] = new PageObject("hotels","/uk/travel/_include/hotelshop.asp","Hotels");
PageArray[4] = new PageObject("hostels","/uk/travel/_include/hostelshop.asp","Hostels");
PageArray[5] = new PageObject("insurance","/uk/travel/_include/insuranceshop.asp","Travel Insurance");
PageArray[6] = new PageObject("shipping","/uk/travel/_include/shippingshop.asp","Shipping");
PageArray[7] = new PageObject("calls","/uk/travel/_include/callshop.asp","Cheap Calls");
PageArray[8] = new PageObject("deals","/uk/travel/_include/dealshop.asp","Late Deals");
PageArray[9] = new PageObject("gifts","/uk/travel/_include/giftshop.asp","Gifts");
PageArray[10] = new PageObject("activities","/uk/travel/_include/leisureshop.asp","Leisure Activities");
PageArray[11] = new PageObject("visas","/uk/travel/_include/visainfo.asp","Visa Information");
PageArray[12] = new PageObject("guides","/uk/travel/countryguides/content_countryguides.inc","Country Guides");
Right. So far so good. Now onto my question. I want to write a script that will control the display of recruitment agencies. These agency objects will have properties like link, imageURL, displayText etc. However, each agency wil have a industryCategory property, but each agency deals with more than one industry sector. Is there any way I can define an array of categories for each potential object and use that array as a property. ie something like this:
AgentArray[0] = new AgentObject("text","link","image",...,"category[0]");
AgentArray[1] = new AgentObject("text","link","image",...,"category[1]");
etc
The only problem with this is that I'm not at all sure how I would define the object. All very well saying:
function AgencyObject(text, link, image, category)
{ this.text = text;
this.link = link;
this.image = image;
this.category = category; }
but how do I modify the category property definition so that the object knows that it's expecting an array? Any hints on how I would iterate through this other array using the object would be great too!
any ideas, oh developer.com gurus?
cheers, people
azz