Jump to content

Store Prompt box input to the DB


snakez

Recommended Posts

Hey guyz help me pls with this problem... im only new to javascript and also to the opensource like(php and mysql). I tried to use a prompt box and store the value into the textbox. But now I want to know how to insert/add the value inputted from a prompt box directly into the mysql database if it is possible.

Link to comment
Share on other sites

A database runs on a server, and JavaScript on the clients machine.Those two cannot communicate with eachother, unless JavaScript calls another server-side language like PHP :) Which can communicate with (any) database(s) :)

Link to comment
Share on other sites

A database runs on a server, and JavaScript on the clients machine.Those two cannot communicate with eachother, unless JavaScript calls another server-side language like PHP :) Which can communicate with (any) database(s) :)
Yes, actually i used php script to communicate with my MySQL DB. it runs on an apache server. I just dont know how to get the value from the promptbox and store it to the Database. I would like some suggestions also if you guyz have any other way aside from inputting from the promptbox wherein I can add or input a new value and store it directly to the databse?
Link to comment
Share on other sites

Yes, actually i used php script to communicate with my MySQL DB. it runs on an apache server. I just dont know how to get the value from the promptbox and store it to the Database. I would like some suggestions also if you guyz have any other way aside from inputting from the promptbox wherein I can add or input a new value and store it directly to the databse?
There are a few ways to do it, but with what you've got, already just do this:
<script language="javascript">function createRequestObject() {	var ro;	var browser = navigator.appName;	if(browser == "Microsoft Internet Explorer"){		ro = new ActiveXObject("Microsoft.XMLHTTP");	}else{		ro = new XMLHttpRequest();	}	return ro; }var AJAX = createRequestObject();function inputVal(inputValue){  AJAX.open('GET','page?value='+inputValue );  AJAX.onreadystatechange = handleConts;  AJAX.send(null);}function handleConts(){if(AJAX.readyState==4){document.getElementById('yourID').innerHTML="added name tot he database, thank you";}}//Now you just have to call it in whateveer function you are usingname=prompt("what yo name is cuz");inputVal(name);</script>

Link to comment
Share on other sites

There are a few ways to do it, but with what you've got, already just do this:
<script language="javascript">function createRequestObject() {	var ro;	var browser = navigator.appName;	if(browser == "Microsoft Internet Explorer"){		ro = new ActiveXObject("Microsoft.XMLHTTP");	}else{		ro = new XMLHttpRequest();	}	return ro; }var AJAX = createRequestObject();function inputVal(inputValue){  AJAX.open('GET','page?value='+inputValue );  AJAX.onreadystatechange = handleConts;  AJAX.send(null);}function handleConts(){if(AJAX.readyState==4){document.getElementById('yourID').innerHTML="added name tot he database, thank you";}}//Now you just have to call it in whateveer function you are usingname=prompt("what yo name is cuz");inputVal(name);</script>

Alright i'll try that one, tnx...
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...