• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Delete A Part of "," seperated Text Box

 
Greenhorn
Posts: 18
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,

Hope you guys are doing well.

My text box takes multiple names and the employee id as input with "," seperating them. If the user tries to delete any character/number from those details, the text field should be cleared.

I have achieved the task of clearing the whole text box if the user hits backspace or delete button (works fine with single name entry )

N w that I have multiple names, I only want to delete the only name and its corresponding employee id text; leaving the rest of the text in the box intact.

Any idea to accomplish the same would be great.

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your mystery code would be?

Eric
 
Sam Pablo
Greenhorn
Posts: 18
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This piece of code accomplishes the above stated reqirement of clearing the textfield. Now I want to delete a part of the text in the text field:

e.g. Sudipto Shekhar (ID2345), Jerrki (ID9301)

If the user tries to delete any character from Jerrki (ID9301) or Sudipto Shekhar (ID2345) , I want to delete the particular name & id group, leaving the other part of the text intact.

I do not need any written code,just a hint on the trick to solve this and the javascript functions that can be used would be fine.

Thank you Eric for showing interest in the post...
 
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I do not need any written code,just a hint on the trick to solve this and the javascript functions that can be used would be fine.


My hint would be, find the last comma and only keep the text up to that comma.
But what if I'm typing a name and I type seap instead of sean, I hit backspace and get annoyed because I have to type it all in again, you should be careful when changing default behaviour of things, especially when people are used to these.

Sean
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having trouble giving a hint because I don't understand the purpose.

Is the reason for deletion of the entire field on backspace or delete convenience for the user or data preservation?

Either way, there is an expected behavior in text boxes. Changing the expected behavior may not enhance the user experience, as noted in the typo comment above.

Please explain!
 
Sean Clark
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

I read your post again and I think I may have misunderstood your requirements:

I only want to delete the only name and its corresponding employee id text; leaving the rest of the text in the box intact.

I'm not sure what this line means.
Perhaps you could show your HTML code with the inputs on it as well?
You haven't mentioned the ID text in anything you have posted.
Sean
 
Sam Pablo
Greenhorn
Posts: 18
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry not provide you guys the details.

Ok, so here it is. I have the following text in my text box:

Sudipto Shekhar (ID2345), Jerrki (ID9301), Sam Pablo(ID1002)

I want these data to be saved in the database. Now, as the data in the textbox is fetched from the database, the user is not supposed to delete any details from the one that is present in the textbox. What I mean is I cannot change Sudipto Shekhar (ID2345) to Sudipto Shekhar (ID2346). And so, if the user tries to change anything from the text, I want to delete the whole text. For example:

Sudipto Shekhar (ID2345), Jerrki (ID9301), Sam Pablo(ID1002). If the user tries to change Sudipto Shekhar (ID2345) to Sudipto Shekhar (ID2346) and hit a backspace or delete button, I want to delete entire Sudipto Shekhar (ID2345), but just that, and want to retain rest of the text in the text box:

Jerrki (ID9301), Sam Pablo(ID1002)

A better example would be how the outlook To: textbox.

I hope I am clear now. Please let me know if I am still not clear.
 
Sean Clark
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

In my opinion I think you have gone the wrong way about this, there are a few ways that people can get around this that it makes it almost a pointless exercise to try.
For example I could turn javascript off in my browser which would prevent your delete/backspace function working.
I could modify the javascript on the page using a tool such as greasemonkey and change as I wish.
Lastly what is to stop me simply clicking in the middle of the ID and changing it, e.g. change Sam Pablo(ID1002) to Sam Pablo(ID109902).

I have a feeling that to do something like outlook it will be a bit more complicated.

Even gmail doesn't do anything like that, however if you look at hotmail, that would be exactly what you want to do.

Sean



 
Sam Pablo
Greenhorn
Posts: 18
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Sean,

Thanks for your thoughts but I am more interested in getting this done as I know that the organization for which I am developing this does not recommend to turn off javascript! also, this same technique is used at lots of pages.

Any ways, thanks for your time
reply
    Bookmark Topic Watch Topic
  • New Topic