MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 28th, 2000, 10:58 AM
brettertd brettertd is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Walla Walla, WA
Posts: 3 brettertd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to brettertd
I've created a workorder tracking web application with Perl/Mysql that uses 2 Mysql tables: One that keeps the information on each workorder, and one that stores the information about each person in our organization.
Right now, you must type in the requestor of the workorder by hand. This is bad because it can cause misspelled names to generate a broken link to their contact information. What I want is a way to query Mysql OnChange of the requestor text field to automatically fill in the correct name from the people database. I want to avoid submitting the form and then returning the message "Requestor not found, please retype".
Is there a way to query onchange of a text field and fill in the field based on information from the table?
I hope this makes sense.

Reply With Quote
  #2  
Old July 28th, 2000, 11:38 AM
christucker
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
If you're suggesting that you want to use some kind of JavaScript to query the database, then I'm afraid you're SOL -- JavaScript being on the client side, it can't create a connection to the DB. However, you have a couple of options to kludge round it. In your Perl, query out the names of all employees and whack them into a JavaScript array in the generated page. Then, when people type in a name validate against that. If you don't want people to have to type in names, instead populate a drop down list. Here's a spot of sample code for the latter:

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
use DBI;
my $dbh = DBI->connect('DBI:mysql:mydb', $user, $pass, { RaiseError => 1 } );

my $sth = $dbh->prepare( 'SELECT emp_name FROM emp' );

$sth->execute;

print '<SELECT name="employees">';

while( my ($emp) = $sth->fetchrow_array ) {
print "<OPTION value="$emp">$emp";
}

$sth->finish;
$dbh->finish;
[/code]

That'll print you out a little snippet of HTML code (once you fix any syntax/semantic errors I've undoubtedly got in there, and have put in the correct names for your tables!).

Reply With Quote
  #3  
Old July 28th, 2000, 12:25 PM
brettertd brettertd is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Walla Walla, WA
Posts: 3 brettertd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to brettertd
Thanks Chris. I use your method for the drop down boxes - query the db to populate the boxes for some other fields but I'll have to use the Javascript array way though because there are 500+ options for the requestor field.

Reply With Quote
  #4  
Old July 28th, 2000, 06:34 PM
brettertd brettertd is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Walla Walla, WA
Posts: 3 brettertd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to brettertd
Hey I got it working with the Javascript array way
Excellent

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > querying Mysql on change of text input


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway