Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7627441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:27:36+00:00 2026-05-31T05:27:36+00:00

I send a string from a server to the Firefox Browser in the format

  • 0

I send a string from a server to the Firefox Browser in the format below:

"KEY:a1 VAL:123.45"

And this string can contain many such records.

Here is the code I have written:

    var e;
    var reply = request.responseText;
    var txt = "", tab, key = "", val = "";
    var x = reply.getElementsByTagName("KEY:");
    for(i = 0; i < x.length; i++)
    {
        txt = x[i].childNodes[0].nodeValue; // "KEY:%c%c VAL:%.2F"
        tab = txt.split(":");
        key = "table_" + tab[1].substring(0,1);
        val = tab[2];
        e = document.getElementById(key);
        e.innerHTML = val;
        e.style.display = "block";
    }

val displays "KEY:a1 VAL:123.45" instead of the expected "123.45" (and of course the key variable is also wrong, not matching a table cell, just picking the first one in the table).

I don’t even know how to display the key and val values (document.write() and alert() do nothing and I don’t see how to trace this code in Firefox).

Any idea, tip, correction, or code example is welcome but please don’t recommend using any library, I want to do it with little code.

EDIT: from the two comments, I understand that there are two distinct ways to proceed: either using DOM objects and HTML tags, or using ‘strings’. I would prefer to keep using the format above, so please guide me to a ‘string’ solution. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:27:36+00:00Added an answer on May 31, 2026 at 5:27 am

    You can use a simple regular expression to extract the information from the string:

    var value = "KEY:a1 VAL:123.45"​,
        pattern = /KEY:(\S+) VAL:(.+)$/g;
    
    var result = pattern.exec(value);
    // result[1] == 'a1'
    // result[2] == '123.45'
    

    In your case, you’d use request.responseText instead of value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Javascript I can send XML string to JSP server (XmlAction.jsp): Javascript Code: var
I've successfully connected to XMPP server (from android XMPP client), and I can send
I would like to send a JSON string from the server side to the
I've writen a function to send and receive message from server like this: //Send
I want to send String from C# to Jave I do it in C#
I'm using GWT RPC to send a string containing a date from the client
I can only send string or numeric values,how to send an array?
I would like to send a html string with a GET request like this
I want to send a couple of values to a web server from my
I'm having a strange problem comparing strings. I send a string to my server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.