DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Discuss "abbr problem" 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 (permalink)  
Old 05-07-2008, 01:19 PM
Contributing Member
 
Join Date: Mar 2008
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default abbr problem

Hi,

I have a textbox so if someone types Cars i want to abr it to CR, If someone types financial i want to FCR

so here is my code
Code:
var getabrdata=document.frm1.abrfield.value;

getabrdata=getabrdata.replace("Cars", "CR");
getabrdata=getabrdata.replace("financial", "FCR");
but its not working can someone tell me what i am doing wrong

todd
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-07-2008, 01:29 PM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 397
Thanks: 12
Thanked 20 Times in 20 Posts
Rep Power: 1
jmurrayhead is on a distinguished road
Default

Please be more descriptive when you say, "it doesn't work".

Anyway, have a look at W3Schools here: JavaScript replace() Method

There are a few things you need to look into:
  • Is there more than one instance? If so, a Global search will need to be performed
  • Should it be case sensitive? Case insensitive? There's a different way to handle these situations
The link I provided should help you.
__________________
jmurrayhead
Did I help you out? Make me popular by clicking the icon!

If you found a post helpful, please click the button in the lower right-hand corner of the post.

Powered by ASP.Net
Reply With Quote
  #3 (permalink)  
Old 05-07-2008, 01:32 PM
Contributing Member
 
Join Date: Mar 2008
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default

what i meant was i have the code on keyup event so when i type in textbox and i type Cars it doesnt change to CR in my span tag when i display what was typed in the textbox

i had tried it with commas and without commas before i posted here but it didnt work
Reply With Quote
  #4 (permalink)  
Old 05-07-2008, 01:40 PM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 397
Thanks: 12
Thanked 20 Times in 20 Posts
Rep Power: 1
jmurrayhead is on a distinguished road
Default

The code that you gave shows you assigning the value of the text to the variable, but it does not show you assigning the variable's new value (after the replace) back to the textbox. So that's probably your problem.
Reply With Quote
  #5 (permalink)  
Old 05-07-2008, 03:33 PM
Contributing Member
 
Join Date: Mar 2008
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default

hi,

I have it like this

Code:
var getabrdata=document.frm1.abrfield.value;

getabrdata=getabrdata.replace("Cars", "CR");
getabrdata=getabrdata.replace("financial", "FCR");

document.getElementById('display').innerHTML=getabrdata;
any idea

todd
Reply With Quote
  #6 (permalink)  
Old 05-09-2008, 08:00 AM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 397
Thanks: 12
Thanked 20 Times in 20 Posts
Rep Power: 1
jmurrayhead is on a distinguished road
Default

Post the HTML that goes with this, specifically the code and the 'display' element.
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Bookmarks

Tags
event, function, javascript, keyup, replace

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


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.


All times are GMT -4. The time now is 01:03 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC7
©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