Results 1 to 2 of 2

Thread: Certain Character Code Replacer

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Exclamation Certain Character Code Replacer

    Ok
    I want to have a little form. Where I enter a line which looks like this:
    emailto=smiesian@comcast.net&FirstName=BOB&LastName=BOB&Age=999&Username=IHATEBOB&UserMame=PASSWORD
    ok
    I want it to look like this:
    <firstname>BOB</firstname><lastname>BOB</lastname>...

    I am thinking i have seen something like this in a text area where i put it into and i press a button and it changes it.

    THIS IS ONLY FOR ME! NOT FOR MY VIEWERS! THANKS!!! HTML and Javascript or if you can, Html , or just javascript. Here are the things i want to change:
    & becomes <
    = becomes />
    ok??

    is that hard?? (I hope not) thanks people really alot for just reading this...

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Could need refinement, I'm not certain if I understood your requirements:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title>Custom Text Transform Demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    function eq_amp(str){
    var str=str.replace(/&$/g, '');
    while(/&([^=]*)=([^&^<]*)(&|$|<)/.test(str))
    str=str.replace(/&([^=]*)=([^&^<]*)(&|$|<)/g, '<$1>$2</$1>$3');
    return str;
    }
    </script>
    </head>
    <body>
    <form action="#">
    <input name="test" type="text" size="100" value="smiesian@comcast.net&FirstName=BOB&LastName=BOB&Age=999&Username=IHATEBOB&UserMame=PASSWORD"><br>
    <input type="button" onclick="this.form['test'].value=eq_amp(this.form['test'].value)" value="Go!"
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •