DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

find words and change

This is a discussion on find words and change within the JavaScript Programming forums, part of the Programming & Scripting category; Hi, If someone enters High School in a text box i want to make it H.S. If someone enters university ...

Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

  #1  
Old June 27th, 2008, 11:59 AM
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 462
Rep Power: 2
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
  #2  
Old June 27th, 2008, 12:03 PM
richyrich's Avatar
Administrator
 
Join Date: Mar 2008
Real name: Rich
Location: Somewhere only we know...
Posts: 1,345
Blog Entries: 6
Rep Power: 8
richyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to all
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
Real name: Joanne
Location: Wide Awake In Dreamland
Posts: 375
Rep Power: 6
mehere is just really nicemehere is just really nicemehere is just really nicemehere is just really nicemehere is just really nice
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:
Mistakes: It could be that the purpose of your life is only to serve as a warning to others.

Questions to Ponder:
Why do banks charge you a "non-sufficient funds fee" on money they already know you don't have?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright © 2008 sbenj69

Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.
Reply With Quote
  #4  
Old July 1st, 2008, 05:55 PM
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 462
Rep Power: 2
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
Wolfmaster
 
Join Date: Mar 2008
Real name: Wolff
Location: Peoria, IL
Posts: 779
Blog Entries: 1
Rep Power: 9
Wolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to behold
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


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 05:13 PM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2