Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » JavaScript: Get info from other web pages
Closed Thread
Old 10-25-2006, 02:48 PM   #1 (permalink)
 
Newb Techie

Join Date: Dec 2005

Posts: 35

paulinnorway is on a distinguished road

Default JavaScript: Get info from other web pages

Hi,

I'm new to JavaScript and I'm still trying to understand it all. The reason I'm "trying" to learn JavaScript is to make my life easier.

My problem is as follows.....

I am starting to sell electrical products locally.
Go to http://www.cafecom.no/shop/ and click on one of the product icons to see how my site displays things.

As you can see, the webpage is split into 3 frames:
- Top frame is the heading
- Middle frame opens an outside site (the site I shop with: http://www.norek.no)
- Bottom frame is blank (I want this to diaplay the price of each item, depending on what the middle frame contains).

As you will notice, the middle frame contains no prices. This is because you need to be logged in as a business to see the prices. Obviously my customers can't be logged in or they would be able to order products without me getting a chance to add my profit to the price!

I'll give you an example of what I would like to do:
As the customer browses, I would like JavaScript to "read" the product number from the middle frame. That's all I need, to get the product number from each page.
Since the format of each page is the same, I was hoping that JavaScript could search for the word "varenummer" (ie. "product number"), and then retrieve the next 6 numbers (which would be the actual product number).

I'm not sure I've explained myself too well, but I hope you understand what I want.

Thanks, and hopefully someone can point me in the right direction....or at least tell me if what I'm asking is even possible with JavaScript!
paulinnorway is offline  
Old 10-25-2006, 04:37 PM   #2 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default

Quote:
I would like JavaScript to "read" the product number from the middle frame...I was hoping that JavaScript could search for the word "varenummer" (ie. "product number"), and then retrieve the next 6 numbers
That's quite ambiguous. Retrieve the numbers for who? The user? The server? What do you want to do with the numbers? Sure, JavaScript can read numbers, but it may not be what you want. Is this a client-side application or a server-side application? If it's a client-side app, JavaScript will work. If not, you'll need to use a CGI script or PHP.
jaeusm is offline  
Old 10-25-2006, 05:39 PM   #3 (permalink)
 
Newb Techie

Join Date: Dec 2005

Posts: 35

paulinnorway is on a distinguished road

Default

Quote:
Originally posted by jaeusm
That's quite ambiguous. Retrieve the numbers for who? The user? The server? What do you want to do with the numbers? Sure, JavaScript can read numbers, but it may not be what you want. Is this a client-side application or a server-side application? If it's a client-side app, JavaScript will work. If not, you'll need to use a CGI script or PHP.
Thanks for the reply.
I'll try to clarify. I want JavaScript to read the page, locate the word "varenummer" (product number), read the next 6 numbers (ie. the actual product number), then use this number to search a database to pick out the corresponding price.
I receive a regularly updated Excel file, which is a list of products, product numbers, prices, etc. I was planning to incorporate this data into perhaps an array within the script. I know that's probably a messy way to do it, but at least I think I'd be able to figure it out.
So, I guess the number is technically for the user so that the script can access the local array and pick out the price. And I suppose that also makes it a client side application.
I hope that helps a bit. I'm learning as I go along, so your input is appreciated.

Also....the Excel file I receive is actually an XML file that I open in Excel because I know nothing about XML but I know a lot about Excel.
paulinnorway is offline  
Old 10-26-2006, 12:26 AM   #4 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default

Quote:
I want JavaScript to read the page, locate the word "varenummer" (product number), read the next 6 numbers (ie. the actual product number), then use this number to search a database to pick out the corresponding price...And I suppose that also makes it a client side application.
Actually, that makes it a server side application because that's where the database is. You can still use JavaScript for various things on the client side, but you'll need to use PHP or a CGI script on the server to query the database.
jaeusm is offline  
Old 10-26-2006, 05:16 AM   #5 (permalink)
 
Newb Techie

Join Date: Dec 2005

Posts: 35

paulinnorway is on a distinguished road

Default

Quote:
Originally posted by jaeusm
Actually, that makes it a server side application because that's where the database is. You can still use JavaScript for various things on the client side, but you'll need to use PHP or a CGI script on the server to query the database.
The database will be an array within the script. So I was thinking that when the user downloaded the web page, the array would be downloaded aswell. Then surely the array/database is on the client side? And therefore Javascript can search through it?
It seems to make sense in my head, but I could be misunderstanding things:o.
paulinnorway is offline  
Old 10-26-2006, 10:01 AM   #6 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default

I suppose you could do it that way, but it's definitely not the typical practice. Usually, you don't want to send your database to the client. However, if it's just a small array, then I would not call it a database (though in the most technical sense, you might get away with it). When we talk about databases, we're usually referring to an actual database software package, like Oracle or MySQL.
jaeusm is offline  
Old 10-26-2006, 10:26 AM   #7 (permalink)
 
Newb Techie

Join Date: Dec 2005

Posts: 35

paulinnorway is on a distinguished road

Default

Quote:
Originally posted by jaeusm
I suppose you could do it that way, but it's definitely not the typical practice. Usually, you don't want to send your database to the client. However, if it's just a small array, then I would not call it a database (though in the most technical sense, you might get away with it). When we talk about databases, we're usually referring to an actual database software package, like Oracle or MySQL.
With my lack of JavaScript knowlege (and zero knowledge of Oracle and MySQL) I'll probably end up trying to do things the non-typical way.
So, do you have any idea how I would go about doing it? Let's say the middle frame contained just one sentence. How would I write a JavaScript in the bottom frame that would read this sentence as a string?
paulinnorway is offline  
Old 10-26-2006, 10:41 AM   #8 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default

I can't really advise you on JavaScript best practices because I never use it. In fact, I despise it. Some people disable JavaScript in their web browsers anyway. If I was working on this project, I would use PHP and keep all the processing on the server side where I have control of it.
jaeusm is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On