+ Reply to Thread
Results 1 to 6 of 6

Thread: abbr problem

  1. #1
    Barn Loyal todd2006 is an unknown quantity at this point todd2006's Avatar
    Join Date
    Mar 2008
    Posts
    514
    Rep Power
    3

    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

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,354
    Blog Entries
    9
    Rep Power
    19

    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
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  3. #3
    Barn Loyal todd2006 is an unknown quantity at this point todd2006's Avatar
    Join Date
    Mar 2008
    Posts
    514
    Rep Power
    3

    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

  4. #4
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,354
    Blog Entries
    9
    Rep Power
    19

    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.
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  5. #5
    Barn Loyal todd2006 is an unknown quantity at this point todd2006's Avatar
    Join Date
    Mar 2008
    Posts
    514
    Rep Power
    3

    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

  6. #6
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,354
    Blog Entries
    9
    Rep Power
    19

    Post the HTML that goes with this, specifically the code and the 'display' element.
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO