Cf And Javascript W/ Database Query

Dec 27, 2004

i'm having the user input their state (from a drop down list) and type in a zipcode (there are 1,143 zip codes in the database to match to)..

what i want to happen is once the user selects the state they live in, and type in a zip code, i need the page to query the database if the user selected Ohio, and match the counties in the database with the zip code they entered, and then create a drop down list of the counties for them to select the one they live in Code:

View 1 Replies


ADVERTISEMENT

Javascript To Submit To A Page To Edit Item From List Returned From A Database Query.

Feb 23, 2006

I am making a webpage that can query a database table of employees
and return them in a html table. Currently I have submit buttons beside
each employee to open the page to edit their details. I have been using
php/HTML to do this, but wondered if it is safe to use javascript to
just click on the name of the employee to jump to the edit page. I've
been looking on the web for sometime about how to do this without any
luck. Any thoughts?

View 1 Replies View Related

Run A Database Query In A JS File?

Mar 19, 2011

Is it possible to connect to a MySQL database from within a jQuery script, run a query, and return the results?

View 24 Replies View Related

Show The Result Of A Database Query, Every Second Or So

Apr 7, 2009

If I want to show the result of a database query, every second or so, is the best method using javascript/ajax with a set interval of a second to call a PHP script and update the DOM, or is there some other method better suited to this that would not have the cpu overhead if there were many users on the site.

View 3 Replies View Related

Set A Variable As A Query Result From A MySQL Database

Apr 15, 2008

Does anyone know how to set a javascript variable as a query result from a MySQL database.

As an example, like this:

Set this query:

I just can't do it. I've tried doing it like this:

But the thing stops my <body onLoad=""> function from working. I'm no expert in Javascript.

View 9 Replies View Related

Pass Database Query Result For Calculation?

Feb 25, 2009

i having problem on passing the database query result to the javascritpt for calculation.i doing a program that need to calculate the total_price for the purchase items. i use getString to get the foodID, f_item and the unit_price from database, then i need to use the unit_price for doing the calculation in javascript. after get the data from database, the unit_price is used to multiple with the qty that user input to calculate the total_price.since there are several row of data get from database, so user need to enter the qty for each item and then press [Calculate_db] button to perform the calculated result. hence, the total_price for each item is calculated and the sum of all the total_price also being calculated and display in the page.now, i having problem on pass the unit_price to the javascript for calculation.

<form name="formCalc2">
<table>
<tr>

[code]....

View 1 Replies View Related

Ajax :: Query Database If Email Already Registered?

Nov 29, 2010

I'm making a little CMS, and I need to use AJAX to query the DB to see if an email is already registered. Here's my code so far:

The javascript:
Code:
<script>
function getEmail(){
var ajaxRequest;
try{
ajaxRequest = new XMLHttpRequest();
} .....

I'll test it by entering javascript:alert(getEmail()) in my browser, and it returns undefined. When I replace return 'valid/taken' to alert valid/taken, it will alert the values correctly, but for some reason it has to be entered twice (I have to hit enter twice in javascript:getEmail() for it to be correctly outputted). I'm relatively new to ajax and I think it might have something to do with the readyState not being correct.

View 2 Replies View Related

Query Parameters At The End Of The JavaScript File

Aug 10, 2007

I am starting to find more web pages that are using a query parameters
after the JavaScript file.

Example can be found at www.opensourcefood.com. Within the source
you'll see: <script src="/shared/scripts/common.js?revision=1.6"
type="text/javascript">.

I am trying to see if there is any big deal to this or a best practice
that is starting to creep up in the JavaScript community. If this is
used only as a way to distinguish what file of JavaScript being used
why not append something inside the file? Has anyone else seen this
or know of more reasons to do this?

View 17 Replies View Related

Javascript Anthology Popup Query

Apr 20, 2007

I have used the code from Sitepoint Javascript anthology (page 130) to create a popup on my pages, however I have a list of pdfs each of which needs to open in a popup and the code only works with the very first in the list. the rest of the pdfs open up in the window as normal. How can I adapt this and would I have to separatly number each id: ?

View 1 Replies View Related

Javascript Alert / Popup Query On Deleting Records...

Dec 27, 2007

On some sites I have worked on, users can delete content from their site. When they go to delete an item, I take them to a page where I pull the item details of the item they are about to delete from the dbase, and say "Are you sure you want to delete so and so". They can choose Yes / No. Yes takes them to action that runs the SQL to delete the item from the dbase. No takes them to the previous page.

I have seen some sites that have managed this process differently, where, instead of being taken to another page, a little pop up box opens saying "Are you sure", with a Yes / No option on it. Yes takes you to delete the item, No leaves them on the page they are on.

Am I right that this method uses Javascript? I know that it won't work if javascript is turned off, but - most people don't turn it off...

View 7 Replies View Related

Javascript And Database

Oct 12, 2010

I have a calculate.js javascript file where all the function that execute the calculation is consist in this file. Now, I want to retrieve a data from the database for javascript calculation and be done in this calculate.js file. I have search a lot of methods to do this but most said cannot do this from a client-side.

View 9 Replies View Related

Creating A Database With Javascript?

Mar 25, 2007

Does anyone know if this is possible to have a online database? Or can I use access to make a database and then post it online and have it work on the internet?

View 2 Replies View Related

HTML/JavaScript, XML Database...

Apr 27, 2006

I want to make a database which I can put on my USB flash drive, with a html interface, and maybe an xml database. Will I be able to do that?

View 1 Replies View Related

Loading Database Data Into Javascript

Nov 20, 2006

im trying to get values from a database and assign them to icons which display on my page. The icons that are generated on the page are generated in javascript- and they do work. Howver i want icons to hold the names that are in the database/table.

how would i do this? would this be using a query result in asp to get the values from the database?? how would i do this? please provide code or guide.

then, how would i assign the database value with the icons???? ive heard javascript arrays??? how would i assign the values??

View 1 Replies View Related

Javascript Database Dependent Dropdowns?

Sep 13, 2006

How would I make my page I have connect to a database using javascript dependent dropdowns? I have all the things I need to get the database working where it displays all the info in the database but I only want it to display based on what they select not all of it.

<?php require_once('Connections/conn_dj.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_industry = "SELECT * FROM tbl_industry ORDER BY industry_name ASC";
$rs_industry = mysql_query($query_rs_industry, $conn_dj) or die(mysql_error());
$row_rs_industry = mysql_fetch_assoc($rs_industry);
$totalRows_rs_industry = mysql_num_rows($rs_industry);

mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_productcategory = "SELECT * FROM tbl_productcat ORDER BY tbl_productcat.productCat_name";
$rs_productcategory = mysql_query($query_rs_productcategory, $conn_dj) or die(mysql_error());
$row_rs_productcategory = mysql_fetch_assoc($rs_productcategory);
$totalRows_rs_productcategory = mysql_num_rows($rs_productcategory);

mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_product = "SELECT * FROM tbl_products ORDER BY tbl_products.products_name";
$rs_product = mysql_query($query_rs_product, $conn_dj) or die(mysql_error());
$row_rs_product = mysql_fetch_assoc($rs_product);
$totalRows_rs_product = mysql_num_rows($rs_product);

mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_outsidena = "SELECT * FROM intl_countries ORDER BY intl_countries.name";
$rs_outsidena = mysql_query($query_rs_outsidena, $conn_dj) or die(mysql_error());
$row_rs_outsidena = mysql_fetch_assoc($rs_outsidena);
$totalRows_rs_outsidena = mysql_num_rows($rs_outsidena);

mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_state = "SELECT * FROM tbl_states ORDER BY tbl_states.`state`";
$rs_state = mysql_query($query_rs_state, $conn_dj) or die(mysql_error());
$row_rs_state = mysql_fetch_assoc($rs_state);
$totalRows_rs_state = mysql_num_rows($rs_state);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DICKEY-john Corporation | Distributors</title>
<link href="_lib/sub.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="Distributor, Sales, Purchase, U.S., International" />
<meta name="description" content="Enter your zip or postal code to find the DICKEY-john distributor nearest you." />
</head>

<body>
<div id="black">&nbsp;</div>
<div id="siteContainer">
<?php include("_inc/topNav.inc"); ?>
<div id="headerContainer">Distributors</div>
<div class="divContainer"><div class="horizDiv"></div><img src="/_img/divEnd.png" alt="div" height="16" width="4" align="right" /></div>
<div id="contentContainer">
<div id="fullContainer">
<div id="stretchCrumbs">
<a href="/index.php">Home</a>
» <a class="high" href="/distributors/">Distributors</a>
</div>
<h1>Distributors</h1>
<p>Search for DICKEY-john distributers by specifying any combonation of the<br />
following classifications: industry, product category, product, and state.</p>
<br />

<br />




<h2>North America</h2>

<table class="setTbl listTbl" width="90%" cellpadding="0" cellspacing="0" border="0">
<tr><td>Industry:</td><td>
<select name="industry" id="center">
<option value="">Select an Industry...</option>
<?php do { ?>
<option value="<?php echo $row_rs_industry['industry_name']; ?>"><?php echo $row_rs_industry['industry_name']; ?></option>

<?php } while ($row_rs_industry = mysql_fetch_assoc($rs_industry)); ?>
</select></td></tr>
<tr><td width="125">Product Category: </td> <td>
<select name="prodcat" id="center">
<option value="">Select a product category...</option>
<?php do { ?>
<option value="<?php echo $row_rs_productcategory['productCat_name']; ?>"><?php echo $row_rs_productcategory['productCat_name']; ?></option>

<?php } while ($row_rs_productcategory = mysql_fetch_assoc($rs_productcategory)); ?>
</select></td></tr>
<tr>
<td>Product:</td> <td>
<select name="prod" id="center">
<option value="">Select a product...</option>
<?php do { ?>
<option value="<?php echo $row_rs_product['products_name']; ?>"><?php echo $row_rs_product['products_name']; ?></option>
<?php } while ($row_rs_product = mysql_fetch_assoc($rs_product)); ?>

</select> </td></tr>
<td>State:</td>
<td> <select name="state" id="center">
<option value="">Select a state...</option>
<?php do { ?>
<option value="<?php echo $row_rs_state['state']; ?>"><?php echo $row_rs_state['state']; ?></option>
<?php } while ($row_rs_state = mysql_fetch_assoc($rs_state)); ?>

</select></td>
</tr>
<tr><td>&nbsp;</td><td><input class="PythonButton" type="submit" value="Find" name="{Button_Name}"></td></tr>
</table>
</form>

<br />
<h2>Outside North America </h2>
<table class="setTbl listTbl" width="90%" cellpadding="0" cellspacing="0" border="0">
<tr><td> <select name="outna" id="center" onchange="javascript:document.centerform.submit()">
<option value="">Select a country...</option>
<?php do { ?>
<option value="<?php echo $row_rs_ousidena['name']; ?>"><?php echo $row_rs_outsidena['name']; ?></option>
<?php } while ($row_rs_outsidena = mysql_fetch_assoc($rs_outsidena)); ?>

</select></td>
</tr></td></tr>
</table>
</form>
</div>
</div>
<?php include("_inc/footer.inc"); ?>
</body>
</html>
<?php
mysql_free_result($rs_industry);

mysql_free_result($rs_productcategory);

mysql_free_result($rs_product);

mysql_free_result($rs_outsidena);

mysql_free_result($rs_state);
?>

View 3 Replies View Related

Apostrophe From Database Stopping Javascript!?!

Nov 8, 2007

we had someone write this script for us a few years ago and we thought it was working fine until this week. It uses javascript to generate a dependant drop down menu eg. Depending on what the user chooses in the first drop down menu, (in this case a manual/book title) the second drop down displays the chapter/category headings that are available within that manual and then the users uploads a file that appears under that heading.

If our user adds a chapter/category heading with an apostrophe in it the script quits and the second drop down does not display the corresponding chapter headings. We are storing the info in a mysql database and use php and javascript to extract the data/build the drop down menus. Code:

View 3 Replies View Related

Output Data From Mysql Database In Javascript?

Mar 16, 2004

Not sure if this is the correct forum as it covers data retrieved from mysql in a .js file...

I need to grab the last 5 rows from my database (2 fields per row) and list all 5 in a table but from within a .js file that I can externally link to.

I can manage the php / mysql and the output to a .php page but how can this be contained within a .js file?

I believe it is possible but after 2 days of searching on google I'm appealing for assistance.

I realise this could be done with a php include or iframe but that isn't an option and the only way available to import this data is via an external javascript script.

View 3 Replies View Related

Javascript Button & Function For PHP/MySQL Database

May 9, 2007

I have this PHP page that has the following functions...Insert Form into Table in MySQL DatabaseDelete Entry from Table in MySQL DatabaseA Link to a separate page where I Edit entries I have coded a PHP function for Delete. Looks like this:

// delete if provided        if (isset($_GET['id'])) {        // query to delete        $query = "delete from student where STUDENT_ID =".$_GET['id'];        //execute query        if ($db->query($query)) {

Somewhere else I query the results and print them into a table. I added a column to this table with a Delete link for each row. Clicking on delete will execute the PHP function to delete.

The link looks like this: PHP Code:

echo "<td><a href=".$_SERVER['PHP_SELF']."?id=".$row[0]."></a></td>";

Likewise the first names also have links when clicked bring the user to another page with a form to edit form data.

The link looks like this: PHP Code:

echo "<td><a href='editstudent.php?id=".$row[0]."'>".$row[1]."</a></td>";

From here however I need to change those links to Buttons. One for Delete and another for Edit and use JavaScript functions to make them work as they originally did. So this is what I've done...

<td><form name='myform1'><input type='button' name='edit' value='Edit'
<td><form name='myform2'><input type='button' name='delete' value='Delete'

Next I need to write functions...this is where I am lost. Usually I'd know what to do when referencing elements in forms, i'd do something like document.formname.inputname, but my problem is those links or should I call them actions are replaced by those new buttons.

Should I put them into a form, or make them hidden, and then name the element? Or should my function look something like this...all I really want to do is to call the function, and have the function just do the action of loading the link (don't know if that sounds clear). I've tried to do this but it does not work.

<script>
function Delete()
{
document.myform2.action="href='$_SERVER['PHP_SELF']."?id=".$row[0]'";
document.myform2.submit();
}
</script>

Can anyone tell me what i am doing wrong, and could you please point me in the right direction?

View 6 Replies View Related

HTML Application - Can Javascript Write To A Local Database?

Jul 23, 2005

IE 6.0 (not interested in other browsers at the moment)

I have looked everywhere I can find to look and googled until I am
cross-eyed and am hoping somebody knows what I'm doing wrong.

I have an HTML application (.hta) working fine, except one thing. I'm
trying to write to a local database from a .htm window (opened from
the main .hta window) and it doesn't work with any of the combinations
I've tried (and I admit to having tried a lot).

Here is one method I've tried:

strSQL = "Update myTable SET myField = 'myValue' WHERE myID = 12;"
var db = new ActiveXObject("ADODB.Connection");
db.Provider = "Microsoft.Jet.OLEDB.4.0";0
db.ConnectionString = "Data Source='c:myDirectorymyDatabase.mdb'";
db.Open;
db.execute(strSQL);

I can easily access the information in the myDatabase.mdb and display
it on the screen.

I can ask for updated information to be input on the screen.

But stuffing that updated information back into the database is the
problem.

Since I'm stuck in an .htm window, I don't have VBScript available, do
I? If VBScript isn't available and it isn't physically possible with
Javascript, then I'll have to revert to .hta windows, where I know I
have VBScript available. But I'd rather do it all in Javascript
within the .htm so as to avoid the security message that pops up when
the .hta opens a new .hta. For various reasons I don't think it is
possible for me to do this whole project within a single .hta.

View 9 Replies View Related

JQuery :: Html To Do Some Database Manipulation - Database Transaction

Jan 11, 2011

Can i use single jquery and html to do some database manipulation i.e. database transaction.

View 1 Replies View Related

Random Word Database - Able To Grab Words From A Database ?

Aug 10, 2010

I want to be able to grab words from a database with javascript. How do I do that?

View 2 Replies View Related

Database Connection - Connect To A Database And Execute Some Queries

Oct 31, 2011

I have been searching how to connect to a database and execute some queries, and then use the data that I get to populate some tables in a web page, all this using javascript.

I am confused because I have seen in some webpages that javascript is not designed to connect with databases, and also I have see other pages where they say that it is possible.

Does anyone know if it is possible to use javascript to connect to a database (informix), and execute some procedures or queries?

View 4 Replies View Related

Java - Database - Post Form To Mysql - Only Posting First Letter Of Word/phrase For Text Input Fields To Mysql Database

Jul 13, 2011

I am having no luck with my post form to mysql. It is only posting the first letter of the word/phrase for the text input fields to the mysql database. It is a photo and text post form. The photo and only first letter of text are posting to database. I am using Jqtouch, jquery, and phonegap.

Here is my form fields:

Here is my java script:

View 3 Replies View Related

Database Connection - Create An Access Database Connection From Within An HTML Page

Aug 8, 2008

I am attempting to create an Access database connection from within an HTML page. I am using Javascript to make the connection and then test a basic UPDATE statement.

The following code is throwing back an error 'UPDATE statment syntax incorrect'

Code:

I thought the syntax was correct, but maybe it is something else?

View 4 Replies View Related

Query String From Src

Jul 23, 2005

I was wondering if you can get the info from the query string in a server-side javascript tag?

Here's what I'm trying to do...

View 8 Replies View Related

Getting Query Strings?

Nov 13, 2007

I need a script that will get a query string and return it's value.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved