Register Blogs FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Sponsored Links

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
 
LinkBack Thread Tools Display Modes
  #1  
Old June 27th, 2008, 11:59 AM
Barn Frequenter
 
Join Date: Mar 2008
Posts: 197
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  
Old June 27th, 2008, 12:03 PM
richyrich's Avatar
Super Moderator
 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 417
Thanks: 26
Thanked 34 Times in 34 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
JavaScript Classic ASP 
Total Awards: 2

Default

Could you post your code?

And how are you calling the JS function?
Reply With Quote
  #3  
Old June 27th, 2008, 12:03 PM
mehere's Avatar
Super Sarcasm Mistress
 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 147
Thanks: 11
Thanked 27 Times in 25 Posts
Rep Power: 1
mehere will become famous soon enough

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:
Quality: The race for quality has no finish line- so technically, it's more like a death march.

Questions to Ponder:
What do you do when you see an endangered animal eating an endangered plant?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright © 2008 sbenj69
Reply With Quote
  #4  
Old July 1st, 2008, 05:55 PM
Barn Frequenter
 
Join Date: Mar 2008
Posts: 197
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  
Old July 2nd, 2008, 09:58 AM
Wolffy's Avatar
Slaprentice of Wolves
 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 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


All times are GMT -4. The time now is 01:39 PM.



Content Relevant URLs by vBSEO 3.2.0