|
-
Oct 18th, 2005, 03:18 PM
#1
Thread Starter
Addicted Member
Is it javascript and xml? if so, how?
Hi
I'd like to know if it's possible to insert data into a form, click a button and check if that data exist on a DB without reloading the page. If so, can it be use to save data to the mentioned DB?
The biggest man you ever did see was once just a baby.
Bob Marley
-
Oct 18th, 2005, 08:31 PM
#2
Frenzied Member
Re: Is it javascript and xml? if so, how?
Hey Yoyo:
Yes, it is possible "to insert data into a form, click a button and check if that data exist on a DB without reloading the page." However, I don't think you can do it with Javascript or XML because neither of them are designed to work with databases directly.
You would need to use a program like Visual Basic or Visual Basic.Net, or C# or something like that.
You usually have a front-end and a back-end to such a program. The front-end is where your form appears and you store your data in the back-end which is a database such as Access, SQL, or some such Database Managment System.
You have to have some way of connecting the front-end and back-end and this is done through a connection object.
Then you make your form(s) and write code to connect to the database and manipulate the information in the database in whatever manner you wish.
I think you can download a limited version of Visual Basic.Net from the Microsoft Web site. This might be the best way to go if you are just starting out with this kind of programming since it is the newest technology.
I personally like Visual Basic 6, but that is just because I have been using it for several years. If I was just starting out with programming I would use Visual Basic.Net.
Someone had a posting on here a few days ago that mentioned Visual Basic Express and they said it was a free download, so you might do a Google search for that.
You could also probably do what you are talking about, in a Web type environment, by using ASP.Net and ADO.Net or PHP and MySql.
Hope this helps.
Good Luck
-
Oct 19th, 2005, 07:36 AM
#3
Thread Starter
Addicted Member
Re: Is it javascript and xml? if so, how?
Thanx for the help AIS4U but I think httprequest is what's goin' to make it work for me. I'm developing a web solution using server side scripting (PHP) to connect to my DB but the problem in some cases users will have to register costumers info and that reloading thing to connect to the DB is just not good.
The biggest man you ever did see was once just a baby.
Bob Marley
-
Oct 19th, 2005, 07:56 AM
#4
Re: Is it javascript and xml? if so, how?
-
Oct 19th, 2005, 12:03 PM
#5
Thread Starter
Addicted Member
Re: Is it javascript and xml? if so, how?
I already know how to send data to a server side script using xmlhttprequest but i'd like to know once i perform the query to the DB, how can i send back the results? i mean, a simple "print" should do it?
The biggest man you ever did see was once just a baby.
Bob Marley
-
Oct 20th, 2005, 02:38 PM
#6
Re: Is it javascript and xml? if so, how?
save this file to your server, then create another file called test.html with some text in it
Code:
<script type="text/javascript" language="javascript">
var http_request = false;
function makeRequest(url) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
// See note below about this line
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('GET', url, true);
http_request.send(null);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
alert(http_request.responseText);
} else {
alert('There was a problem with the request.');
}
}
}
</script>
<span
style="cursor: pointer; text-decoration: underline"
onclick="makeRequest('test.html')">
Make a request
</span>
when you click on the text it should return the contents of the test.html file. I haven't tried it, but I would imagine that if you replaced test.html with a php or asp file that connects to a db and then returns results you should get what your looking for.
-
Oct 21st, 2005, 02:54 AM
#7
Re: Is it javascript and xml? if so, how?
Quick update, I tried replacing the html file with a php file that connects to a database and displays the results of a query. It worked fine.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|