473,324 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Big help needed - Deleting specific values from textfield...

Rob
Hi everyone,
I have a form that has several disabled text fields. In these text
fields, I have initial values. Next to each text field lies a "copy"
button. When clicked, the content of the disabled text field is
appended to the content of another textfield, the only one that isn't
disabled (therefore the user can copy content from the other text
fields, and also add what they want). I also have a remove button,
which clears the content of that one non-disabled text field.

Pretty easy so far.

Here's the problem. Imagine I copy the content from textfield 1 into
the blank text field, then do the same for textfield 2 and 3.

Between each "insert", I've added a comma. So the non-disabled
(active) text field would have the following content:
content1, content2, content3,

Now say that the user wants to remove content2, without removing the
rest, how could I go about doing this?
Jul 23 '05 #1
2 1312
dj******@hotmail.com (Rob) writes:
Now say that the user wants to remove content2, without removing the
rest, how could I go about doing this?


Are you sure the value are disjoint, i.e., "content2" is not a substring
of any of the other texts?

In that case, you can do, e.g.,:

string = string.split("content2, ").join("");

or

var idx = string.indexOf("content2, ");
var len = "content2, ".length;
string = string.substring(0,idx)+string.substring(idx+len);

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
Rob wrote on 08 mei 2004 in comp.lang.javascript:
So the non-disabled
(active) text field would have the following content:
content1, content2, content3,

Now say that the user wants to remove content2, without removing the
rest, how could I go about doing this?


if content1,2,3 do not contain comma's:
Click on the following:
<div onclick="removecenter(this)">
content1, content2, content3
</div>

<script>
function removecenter(x){
x.innerHTML=x.innerHTML.replace(/,[^,]*,/,",")
}
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Frank Py | last post by:
I have 4 possible values that I would like to populate a text box with depending on which 4 values are sleected in a select box. Is there an example out there for this? Thanks Frank ***...
1
by: Suresh | last post by:
How do I insert a char into the textfield on the keypress event of another textfield? I have two textboxes, "text1" and "text2". Important: "text1" is outside the table. "text2" is inside...
6
by: Sebi | last post by:
Hello all, I'm thinking about overwriting the ListItem, so it can contain x additional values (not only one). Has anybody ever tried this? Has someone got an example (C#)? Can DropDownList...
6
by: Sanjay | last post by:
Hi, Is it possible to save all the names/values of a form to another memo textfield before a Insert to the database then when required on another page split that memo textfield into the name and...
62
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image();...
6
by: Ian Davies | last post by:
Hi me again, sorry to be a pain. Ive been struggling with this one all day. Hope you can understand whats happening. First my script is below. Have a look and I'll explain at the bottom what it...
3
chunk1978
by: chunk1978 | last post by:
hi there... i'm trying to make one text field contain the value of another... i'm assuming there's a really simple solution... here's a code i quickly wrote to further explain my issue: ...
4
by: Tomislav | last post by:
Helo, as I am new to PHP my question is related to pure basics. I wrote simple PHP file for automated mail sending. It sends, of course, mail with fixed text but I need "mail()" function to...
8
by: sneddo | last post by:
Ok I am trying to do the above, I have got a script that will restrict the length but it requires the user to enter the field and hit a key, before it will work. This would normaly be find, but...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.