Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

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 Codewalkers Forums Sponsor:
  #1  
Old December 4th, 2005, 06:47 PM
jweizenblut jweizenblut is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Miami, Fl. US
Posts: 522 jweizenblut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 29 sec
Reputation Power: 2
Send a message via AIM to jweizenblut Send a message via Yahoo to jweizenblut
Prevent Duplicate Entries...

I have a form select object that loads the options from my database. The code for it as follows:

php Code:
Original - php Code
  1.  
  2. include('/webserver/security/5206/includes/sql_connect.php');
  3. $fields_needed = "unique_id, class_name";
  4. $query_class_names = "SELECT $fields_needed FROM training_classes ORDER BY class_name";
  5. $result_class_names = mysql_query($query_class_names);
  6. while ( $myrow = mysql_fetch_array($result_class_names))
  7.   {
  8.     echo "<option value=".$myrow["unique_id"].">".$myrow["class_name"]."</option>";
  9.   }
  10. mysql_close($server);


I also have a text input as follows:
php Code:
Original - php Code
  1.  
  2. <input class="200_10_entry_area" type="text" name="new_class_name" maxlength="30">


What I want to do is have JavaScript check all the current names for the select object and if any of them match what has been entered in the form input, for an error message to be displayed and focus back to the form input.

Any help would be appreciated.

Reply With Quote
  #2  
Old December 4th, 2005, 09:16 PM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: Prevent Duplicate Entries...

if you want javascript to do this you need to load all the existing entries for the select box into a javascript array.

I would do a query at the top of the page and pull all the entries and store them in an array, then write a javascript function to validate the text area usuing a for loop to populate the array with php variables.

then the same php array can be used to create your list box without making another query

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Prevent Duplicate Entries...


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 3 hosted by Hostway
Stay green...Green IT