DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Discuss "find words and change" in the JavaScript Programming forum.

JavaScript Programming - Javascript is a cross-browser client-side scripting language. Discuss Javascript and AJAX related scripts here.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old June 27th, 2008, 11:59 AM
Contributing Member

 
Join Date: Mar 2008
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default find words and change

Hi,

If someone enters High School in a text box i want to make it H.S.

If someone enters university in a textbox I want to make it Unv

I tried the replace function in javascript but i think i messed it up somewhere

Any idea

todd
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old June 27th, 2008, 12:03 PM
richyrich's Avatar
Moderator

 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 320
Thanks: 22
Thanked 23 Times in 23 Posts
Rep Power: 1
richyrich is on a distinguished road

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default

Could you post your code?

And how are you calling the JS function?
Reply With Quote
  #3 (permalink)  
Old June 27th, 2008, 12:03 PM
mehere's Avatar
Mistress of Sarcasm

 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 111
Thanks: 8
Thanked 19 Times in 17 Posts
Rep Power: 1
mehere is on a distinguished road

Awards Showcase
Microsoft SQL Server Classic ASP 
Total Awards: 2

Default

for one, post your code. for two, what if they type in Univ ... or College or etc. well, hopefully you get what i'm getting at. why not use a drop down box so that they will always be what you want them to be.
__________________
Quote of the Month:
Strife: As long as we have each other, we'll never run out of problems.

Questions to Ponder:
Should vegetarians eat animal crackers?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright © 2008 sbenj69
Reply With Quote
  #4 (permalink)  
Old July 1st, 2008, 05:55 PM
Contributing Member

 
Join Date: Mar 2008
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default

hi,
this is the code i have

Code:
if (getinstnamemem.length > 0)
{
getinstnamemem=getinstnamemem.replace("High School", "H.S.");
getinstnamemem=getinstnamemem.replace("University", "Unv");
}

but if someone enters university it doesnt change it to Unv

can someone tell me how i can make it happen

todd
Reply With Quote
  #5 (permalink)  
Old July 2nd, 2008, 09:58 AM
Wolffy's Avatar
Slaprentice of Wolves


 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 146
Thanks: 1
Thanked 23 Times in 20 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

There is really no good way to do what you are trying to do. The number of permutations are almost infinite, even if you upper or lower case the string prior to doing the replace:
High School
High School
High School
University
Univ.
Univ
are all different.
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change to Reputation System jmurrayhead Announcements 0 June 2nd, 2008 09:57 PM


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.

Web Directory & SEO Services
dirroot web directory


All times are GMT -4. The time now is 07:38 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 DeveloperBarn.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46