473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Reading data from remote URL

Forgive me, I am new to javascript ( about 1 week playing with it ). I am
proficient in C, perl, python, java, etc... but no javascript.

I wrote an applet about 1 million years ago that has dynamic drop down
menus.

I have a couple of C programs that take GET requested data and displays
matching results from a database query...

For example... www.mydomain.com/cgi-bin/getTypes?code=6 might display
76|45|54|122|449|2020 and getTypes?code=7 might display 88|22|32|66|92

Now, I want to get that data into my javascript so I can break it down and
populate a drow down menu.

How can I retrieve this data?

Thanks for any help JS gurus.
Jul 23 '05 #1
7 7201
"news.west.cox.net" <se*********@cox.net> wrote in message
news:YgZjd.245349$a85.60139@fed1read04...
Forgive me, I am new to javascript ( about 1 week playing with it ). I am
proficient in C, perl, python, java, etc... but no javascript.

I wrote an applet about 1 million years ago that has dynamic drop down
menus.

I have a couple of C programs that take GET requested data and displays
matching results from a database query...

For example... www.mydomain.com/cgi-bin/getTypes?code=6 might display
76|45|54|122|449|2020 and getTypes?code=7 might display 88|22|32|66|92

Now, I want to get that data into my javascript so I can break it down and
populate a drow down menu.

How can I retrieve this data?

Thanks for any help JS gurus.


Will this help?

<html>
<head>
<title>getTypes.htm</title>
<script type="text/javascript">
function getTypes() {
var code = location.search;
code = code.charAt(code.length-1);
code = parseInt(code,10);
var list = new Array();
list[6] = "76|45|54|122|449|2020";
list[7] = "88|22|32|66|92";
var item = list[code].split("|");
var form = document.forms[0];
form.Item.options.length = 0;
for (var i=0; i<item.length; i++) {
form.Item.options[i] = new Option(item[i],i);
}
}
</script>
</head>
<body onload="getTypes()">
<form>
<select name="Item">
</select>
</form>
</body>
</html>

Except that you would invoke it by:
www.mydomain.com/cgi-bin/getTypes.htm?code=6
not
www.mydomain.com/cgi-bin/getTypes?code=6
Jul 23 '05 #2


news.west.cox.net wrote:

I have a couple of C programs that take GET requested data and displays
matching results from a database query...

For example... www.mydomain.com/cgi-bin/getTypes?code=6 might display
76|45|54|122|449|2020 and getTypes?code=7 might display 88|22|32|66|92

Now, I want to get that data into my javascript so I can break it down and
populate a drow down menu.

How can I retrieve this data?


If you have server-side scripting then use it instead of JavaScript e.g.
build a CGI script that generates the necessary HTML for the <select>
and its <option> elements.
As for JavaScript making HTTP requests check
http://www.faqts.com/knowledge_base/.../17226/fid/616
and
http://jibbering.com/2002/4/httprequest.html

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3
>> Forgive me, I am new to javascript ( about 1 week playing with it ). I
am
proficient in C, perl, python, java, etc... but no javascript.

I wrote an applet about 1 million years ago that has dynamic drop down
menus.

I have a couple of C programs that take GET requested data and displays
matching results from a database query...

For example... www.mydomain.com/cgi-bin/getTypes?code=6 might display
76|45|54|122|449|2020 and getTypes?code=7 might display 88|22|32|66|92

Now, I want to get that data into my javascript so I can break it down
and
populate a drow down menu.

How can I retrieve this data?

Thanks for any help JS gurus.


Will this help?

<html>
<head>
<title>getTypes.htm</title>
<script type="text/javascript">
function getTypes() {
var code = location.search;
code = code.charAt(code.length-1);
code = parseInt(code,10);
var list = new Array();
list[6] = "76|45|54|122|449|2020";
list[7] = "88|22|32|66|92";
var item = list[code].split("|");
var form = document.forms[0];
form.Item.options.length = 0;
for (var i=0; i<item.length; i++) {
form.Item.options[i] = new Option(item[i],i);
}
}
</script>
</head>
<body onload="getTypes()">
<form>
<select name="Item">
</select>
</form>
</body>
</html>

I guess I was not clear. Correct me if I am wrong ( and I hope I am ) but,
because JavaScript is client-side, it cannot make database querries.

Retrieving a results set from a database withing a Java Applet is a drawn
out, tedious task. So, in an applet I wrote I use some intermediate C
programs to do the database querries and print the results. In my applet I
open an http connection, send the URL, and read in the data printed to the
screen. Then, I repopulate the drop downs with the results ( after I split
them up .)

I want to do this in javascript now...

I know how to populate drop downs like the example above shows... but how
can I go open a URL like .../cgi-bin/getTypes?code=24 and retrieve the data
within JS?

Thanks for any help


Jul 23 '05 #4
>
If you have server-side scripting then use it instead of JavaScript e.g.
build a CGI script that generates the necessary HTML for the <select> and
its <option> elements.


This is something that I do all the time. But, in order to do that, my
script has to keep getting submitted with onchange="myform.submit();" calls.
I could have a perl script say... and in that script I have the value, label
option pairs in a hash. Then, when the select menu changes, the form is
submitted, and the next drop down is populated based on the new parameter
received. Then repeated for this second drop down.

But... I don't want the page to reload, I just want the drop downs to
repopulate without the browser refreshing.


Jul 23 '05 #5


Sean Berry wrote:

But... I don't want the page to reload, I just want the drop downs to
repopulate without the browser refreshing.


Use the links then I posted in my first reply, in some browsers (IE/Win,
Mozilla, Netscape, Safari 1.2) you can do HTTP request with script but
of course that will fail if someone tries to use your page with
JavaScript disabled or another browser not supporting XMLHttpRequest so
in the end you need to have your CGI solution nevertheless.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #6
"Sean Berry" <se**@buildingonline.com> wrote in message
news:Tf6kd.123550$hj.31349@fed1read07...

[snip]
I guess I was not clear. Correct me if I am wrong ( and I hope I am ) but, because JavaScript is client-side, it cannot make database querries.

Retrieving a results set from a database withing a Java Applet is a drawn
out, tedious task. So, in an applet I wrote I use some intermediate C
programs to do the database querries and print the results. In my applet I open an http connection, send the URL, and read in the data printed to the
screen. Then, I repopulate the drop downs with the results ( after I split them up .)

I want to do this in javascript now...

I know how to populate drop downs like the example above shows... but how
can I go open a URL like .../cgi-bin/getTypes?code=24 and retrieve the data within JS?

Thanks for any help


It sounds like you might want ASP (Active Server Pages) or comparable
technology.
Jul 23 '05 #7
Although I did not do this how I first set out to... I did indeed get it
finished.

OLD APPLET DROP DOWNS
www.aquaticwhirlpools.com/aqua_browse2.pl

NEW JAVASCRIPT DROP DOWNS
www.aquaticwhirlpools.com/aqua_browse4.pl
Jul 23 '05 #8

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

Similar topics

1
by: Red Golpe | last post by:
I've managed to read from a local database using only javascript and the DAO ActiveX object, but I can't make it work with a remote database. When I change the connection string from "C:\..." to...
4
by: JoelWhitehouse | last post by:
Hi! I want to write a script that will read a .php file on a remote server and print to the current page a portion of the text contained in the remote file. I am just wondering what the best...
4
by: Greg Smith | last post by:
I have an old application that analyzes the data in the event log on one of our servers. I would like to convert it to C#. Does anybody know of any examples of reading the event log on a remote...
24
by: ej1002 | last post by:
Hi I have developed a Windows Application(C# Windows Form) which will get the IFrame Source of the page it is navigating using Webbrowser Control. Now I want do this in ASP.Net web application(C#...
11
by: pmclinn | last post by:
How should one import data that is stored in the following fashion? <Restaurants> - <Restaurant> <Category>American Restaurants</Category> <Name>APPLEBEES</Name> <Address>1273 HOOKSETT RD,...
7
by: John Pote | last post by:
Hello, help/advice appreciated. Background: I am writing some web scripts in python to receive small amounts of data from remote sensors and store the data in a file. 50 to 100 bytes every 5 or...
4
by: John Pote | last post by:
Hello, help/advice appreciated. Background: I am writing some web scripts in python to receive small amounts of data from remote sensors and store the data in a file. 50 to 100 bytes every 5 or...
2
by: Larry Bertolini | last post by:
Is there a way to read data from a linked server, within a transaction, without using DTC? The data on the linked server is static, therefore there is no need for two-phase commit. There is no...
9
by: Macca | last post by:
Hi, I have a synchronous socket server which my app uses to read data from clients. To test this I have a simulated client that sends 100 byte packets. I have set up the socket server so...
4
ammoos
by: ammoos | last post by:
Hi Friends, I need to read data from an excel sheet. I am keeping this excel sheet in a remote machine. I am using OLEDB connection to read the data from this excel sheet. But when I am trying to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.