473,799 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with Objects

Hello All:

I am trying to figure out how to use objects properties in my code so
when the page loads All my properties are in object where I can use
elsewhere in my page.

I am new to JavaScrip Objects so any help would be appreciated.

Thanks
SPS

function onload()
{
var id = 25;
var previewProperti es = new PreviewProperti es();
previewProperti es = tripPreviewProp erties(id);

//Need to Display lat,lon & scale
//alert(previewPr operties.lat); This Does Not Work

}

//Preview Properties Object
function PreviewProperti es(lat,lon) {
this.lat = lat;
this.lon = lon;
this.scale =4;
}
function tripPreviewProp erties(id)
{

AjaxCommon.Goog leMapsTripPrevi ewProperties(id ,tripPreviewPro perties_callbac k);
}
function tripPreviewProp erties_callback (res)
{
properties = new PreviewProperti es(res.value.La t,res.value.Lon );

// Corect Properties are Displayed
alert(propertie s.lat + "\n" + properties.lon );

return properties;
}

Aug 3 '05 #1
2 1295
st********@gmai l.com wrote:
Hello All:

I am trying to figure out how to use objects properties in my code so
when the page loads All my properties are in object where I can use
elsewhere in my page.

I am new to JavaScrip Objects so any help would be appreciated.

[...]

The first part of any design is knowing the requirements. What are
the objects for and what data will they hold?

For example, below is a simple object to hold way points and some code
to present the values for each point.

<script type="text/javascript">

var wayPoint = {};
wayPoint.City_1 = { lat:150.0, lon:27.2, scale: 5 };
wayPoint.City_2 = { lat:151.2, lon:27.5, scale: 5 };
wayPoint.City_3 = { lat:153.4, lon:27.6, scale: 5 };

function showWaypoint( el ){
var wp = el[el.selectedInde x].value;
var ref = wayPoint[ wp ];
if ( '' != ref ) {
alert( wp
+ '\nLatitude: ' + ref.lat
+ '\nLongitude: ' + ref.lon
+ '\nScale: ' + ref.scale
);
}
}
</script>

<select onchange="showW aypoint(this);" >
<option value="City_1"> City 1</option>
<option value="City_2"> City 2</option>
<option value="City_3"> City 3</option>
</select>

or done slightly differently:

var wayPoint = {
City_1 :{ lat:150.0, lon:27.2, scale: 5 },
City_2 :{ lat:151.2, lon:27.5, scale: 5 },
City_3 :{ lat:153.4, lon:27.6, scale: 5 }
};

Or you could give wayPoints some methods to add way points and then
feed it data from an array. But it seems pointless to create an array
just to feed to an object when you could load the object with the data
in the first place and not bother with the method.

But if you want to modify the object's data it may be better if the
methods belong to the object.

As I said, it all depends on what you want this thing to do.

--
Rob
Aug 3 '05 #2
RobG wrote:
[...]
For example, below is a simple object to hold way points and some code
to present the values for each point.

<script type="text/javascript">

var wayPoint = {};
wayPoint.City_1 = { lat:150.0, lon:27.2, scale: 5 };
wayPoint.City_2 = { lat:151.2, lon:27.5, scale: 5 };
wayPoint.City_3 = { lat:153.4, lon:27.6, scale: 5 };

function showWaypoint( el ){
var wp = el[el.selectedInde x].value;
var ref = wayPoint[ wp ];
if ( '' != ref ) {


Sorry, that was not meant to be there (it's a pretty silly test)

var wp = el[el.selectedInde x].value;
var ref;
if ( '' != wp && (ref = wayPoint[wp]) ) {
and the first option should have no value:

<select onchange="showW aypoint(this);" >
<option>Selec t a city</option>
...
[...]
--
Rob
Aug 3 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1946
by: Tommy Lang | last post by:
I am working on this project and I need some help/pointers/comments to get me started, I am stuck. The program will be used to store information in an array while it is running. I need to store objects of my classes Person(superclass), Student(inherit Person), Teacher(inherit Person) in that array. The name will be the unique key. These classes are all working ok. I want to be able to add, remove, find etc. objects. To all of this, I...
5
2126
by: Jeff Greenberg | last post by:
Not an experienced c++ programmer here and I've gotten myself a bit stuck. I'm trying to implement a class lib and I've run into a sticky problem that I can't solve. I'd appreciate any help that I can get! Consider 3 classes in the following heirarchy: base / \ deriv1 deriv2 \
2
4449
by: KoliPoki | last post by:
Greetings. I'm having a little trouble with a query. The idea is simple I need to display a list of recently unique visited URLs and the last time I visited. I have 2 table one stores the user and time/date and another has the URL. So all I need is the URL (no duplicates) and the last visit.
4
2834
by: Mingus Tsai | last post by:
Hello- please help with unpickling problem: I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows XPhome system. My problem is with using cPickle to deserialize my pickled arrays of datetime.datetime instances. The following is the code I have written: import cPickle, datetime import Numeric
1
2645
by: aredo3604gif | last post by:
On Sun, 10 Apr 2005 19:46:32 GMT, aredo3604gif@yahoo.com wrote: >The user can dynamically enter and change the rule connection between >objects. The rule is a "<" and so given two objects: >a < b simply means that b < a can't be set, also it must be a != b. >And with three objects a < b , b < c means a < c > >I studied Quick Union Find algorithms a bit and if I understood them >correctly, once the user gives the input setting the...
2
1598
by: duncanblacksmithmath | last post by:
I know a lot of you have seen this before but I have worked on the program and have gotten it to work thus far but I need help getting these two functions to work and implementing them. Here is what I have been trying to work out for these functions but can't get them to fully work out for me. information: A function to access an element of a list by its index called access i(LL, i). It traverses the list LL and returns the address of...
4
2433
by: Tarun Mistry | last post by:
Hi all, I have posted this in both the c# and asp.net groups as it applies to both (apologies if it breaks some group rules). I am making a web app in asp.net using c#. This is the first fully OO application I will be making, also my first .NET application, so im looking for any help and guidance. Ok, my problems are todo with object and database abstraction, what should i do.
5
1622
by: =?Utf-8?B?QkY=?= | last post by:
I want to improve the response time of my application. I have 3 options: 1. Run both ASPX pages and our business objects on web server and use web farm technology. 2. Move our business objects to COM+ as serviced components. Then run our web pages on web servers in a web farm. And run COM+ on other clustered servers. 3. Move our business objects to .NET remoting or web service. Run our web pages on one web farm. Run .NET remoting or...
2
1653
by: mia23 | last post by:
Hello, I am a java beginner and I need series help in solving this program; my assignment is due after 2 days and I can't understand this program . This is THE PROGRAM:  The ABC medical clinic needs your help in building a Java application that can help in keeping track of patients, appointments, and clinic activities.  Create a class Patient from which we can create objects to handle information about different patients. Each patient is...
5
1427
by: PeaceLovinHippy | last post by:
Hello im new to java & im working on some mods for a game - below is a small part which im working on . however im getting errors due to something wrong in the code - can anyone please help me understand what im doing wrong ? (below the following code is also the errors i get) THX in advance } static { Property.set ((class$com$maddox$il2$objects$air$CockpitB29_TGunner == null ?...
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9544
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.