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

  • Home
  • SEARCH
  • 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 168779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:30:48+00:00 2026-05-11T12:30:48+00:00

In my site, I would like to implement a textbox where people can input

  • 0

In my site, I would like to implement a textbox where people can input a set of strings separated by a separator character.
For example the tags textbox at the bottom of this page: tags(strings) delimited by space(separator).
To make it more clear to the user, it would make a lot of sence to give each string a different background color or other visual hint.
I don’t think this is possible with a regular input[text] control.

Do you deem it possible to create something like that with javascript? Has somebody done this before me already? Do you have any other suggestions?

  • 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. 2026-05-11T12:30:48+00:00Added an answer on May 11, 2026 at 12:30 pm

    Basic Steps

    1. Put a textbox in a div and style it too hide it.
    2. Make the div look like a text box.
    3. In the onClick handler of the div, set the input focus to the hidden text box.
    4. Handle the onKeyUp event of the hidden text box to capture text, format as necessary and alter the innerHtml of the div.

    Tis quite straightforward. I’ll leave you to write your formatter but basically you’d just splitString on separator as per the Semi-Working-Example.

    Simple Outline

    <html>     <head>     <script language='javascript' type='text/javascript'>     function focusHiddenInput()     {         var txt = document.getElementById('txtHidden');         txt.focus();     }      function formatInputAndDumpToDiv()     {         alert('Up to you how to format');     }     </script>     </head>      <body>     <div onclick='focusHiddenInput();'>     Some label here followed by a divved textbox:     <input id='txtHidden' style='width:0px;' onKeyPress='formatInputAndDumpToDiv()' type='text'>     </div>     </body>     </html> 

    Semi-Working Example

    You still need to extend the click handlers to account for tag deletion/editing/backspacing/etc via keyboard…. or you could just use a click event to pop up another context menu div. But with tags and spacer ids identified in the code below that should be pretty easy:

    <html>     <head>     <script language='javascript' type='text/javascript'>      var myTags=null;      function init()     {         document.getElementById('txtHidden').onkeyup= runFormatter;     }      function focusHiddenInput()     {         document.getElementById('txtHidden').focus();     }      function runFormatter()     {         var txt = document.getElementById('txtHidden');         var txtdiv = document.getElementById('txtBoxDiv');         txtdiv.innerHTML = '';         formatText(txt.value, txtdiv);     }      function formatText(tagText, divTextBox)     {         var tagString='';         var newTag;         var newSpace;         myTags = tagText.split(' ');         for(i=0;i<myTags.length;i++) {             newTag = document.createElement('span');             newTag.setAttribute('id', 'tagId_' + i);             newTag.setAttribute('title', myTags[i]);             newTag.setAttribute('innerText', myTags[i]);              if ((i % 2)==0) {            newTag.style.backgroundColor='#eee999';           }         else         {            newTag.style.backgroundColor='#ccceee';          }             divTextBox.appendChild(newTag);             newTag.onclick = function(){tagClickedHandler(this);}              newSpace = document.createElement('span');             newSpace.setAttribute('id', 'spId_' + i);             newSpace.setAttribute('innerText', ' ');             divTextBox.appendChild(newSpace);              newSpace.onclick = function(){spaceClickedHandler(this);}        }     }      function tagClickedHandler(tag)     {       alert('You clicked a tag:' + tag.title);       }         function spaceClickedHandler(spacer)     {       alert('You clicked a spacer');         }         window.onload=init;     </script>     </head>      <body>     <div id='txtBoxDivContainer'>     Enter tags below (Click and Type):<div id='txtBoxDiv' style='border: solid 1px #cccccc; height:20px;width:400px;' onclick='focusHiddenInput();'></div>     <input id='txtHidden' style='width:0px;' type='text'>     </div>     </body>     </html> 

    Cursor

    You could CSS the cursor using blink (check support) or otherwise just advance and hide as necessary an animated gif.

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

Sidebar

Ask A Question

Stats

  • Questions 79k
  • Answers 79k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You have to define the ViewController that the UIImageView is… May 11, 2026 at 4:11 pm
  • Editorial Team
    Editorial Team added an answer Use event.preventDefault(): $('a.tab').click(function(event) { event.preventDefault(); // this is the key… May 11, 2026 at 4:11 pm
  • Editorial Team
    Editorial Team added an answer I'm not sure I follow. If you've bound the Background… May 11, 2026 at 4:11 pm

Related Questions

I want to check whether the user is viewing my site from a mobile
I have a website with a contact form. User submits name, email and message
Sorry for the slightly rubbish title. I could not think how to describe this
I would like to fetch a SSL page in Java. The problem is, that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.