How To Edit The Same Text Box?

P

pbd22

Hi.

Can somebody tell me how I would go about allowing the user
to click on a link to put content in text box A and then another
link to put different content in text box A and so on. Finally,
when onsubmit is fired, all the content created for each individual
link (using the same text box) is sent to SQL Server.

How do I reuse the same text box in this manner?

Thanks!
 
T

töff

You could append the "content" from each click into a variable,
and then for each click the textbox simply displays the text for the
most recent click.

Then you are not sending the textbox value to the server; you send the
value of the variable, which is the whole history of all the clicks, not
just the most recent click that shows in the textbox.
 
S

shimmyshack

You could append the "content" from each click into a variable,
and then for each click the textbox simply displays the text for the
most recent click.

Then you are not sending the textbox value to the server; you send the
value of the variable, which is the whole history of all the clicks, not
just the most recent click that shows in the textbox.

kind of like:


function addTTextBox(str)
{
var strSeparator = '\n';
document.getElementById('textbox_id').value += strSeparator + str;"
}
then in the link

onclick="addToTextBox(this.innerHTML)"

but this leaves you to say more about what you mean "text from links"
do you mean the innerHTML, the href, etc... that part was not very
well explained,
 
L

Lee

pbd22 said:
Hi.

Can somebody tell me how I would go about allowing the user
to click on a link to put content in text box A and then another
link to put different content in text box A and so on. Finally,
when onsubmit is fired, all the content created for each individual
link (using the same text box) is sent to SQL Server.

How do I reuse the same text box in this manner?

You can't start without being able to clearly define what you want.

You don't want the links to "put different content" into the text
box. You want them to "append new content" to any value which may
already be there, right?

And I don't think you really want the values sent when onsubmit
fires. You want them sent when the form is submitted, right?

Why are you using links instead of buttons?
What specific part of this assignment are you having trouble with?
Can you show us what you've got so far?


--
 
P

pbd22

kind of like:

function addTTextBox(str)
{
var strSeparator = '\n';
document.getElementById('textbox_id').value += strSeparator + str;"}

then in the link

onclick="addToTextBox(this.innerHTML)"

but this leaves you to say more about what you mean "text from links"
do you mean the innerHTML, the href, etc... that part was not very
well explained,

OK, thanks both for your responses.
but this leaves you to say more about what you mean "text from links"

I have a display div on the page showing files for upload. I want the
user to associate descriptions and a title for each file. So, the
display div has, say, five files waiting for upload inside it. Each
file has an anchor tag surrounding it making it a link. when clicked,
that activates the text box that is already visible lower down on the
page. So, when the first file in the list is clicked that would allow
the user to fill out text for this upload. When the next file in the
list is clicked, the text box becomes empty and the user can fill in
the associated text. And so on. When a user wants to go back to a
given entry, all he need to is click on a link in the "files" list and
the entry for that given file appears. It's sort of like an ajax
database query but, without the trip to the server.

Here Is A "VIEW SELECTION SOURCE" of three files in the queue:

<div id="files"><div style="text-decoration: none;"><a href="#nogo"
style="color: blue; text-decoration: none;">get_file.txt </a></
div><div style="text-decoration: none;"><a href="#nogo" style="color:
blue; text-decoration: none;">monkey.flv </a></div><div style="text-
decoration: none;"><a href="#nogo" style="color: blue; text-
decoration: none;">upload_code.rtf</a></div></div>
 
P

pbd22

Lee,

Thanks for your response.
You don't want the links to "put different content" into the text
box. You want them to "append new content" to any value which may
already be there, right?

This isn't correct. I want to give the user the feeling that, after
clicking
a link (which, in this case, is acting as a button) to a file the text
box will be
empty and awaiting whatever he wants to write. Should he write
something
for a given file and then go back to it, the text he associated with
this particular file will appear (and, no others).
And I don't think you really want the values sent when onsubmit
fires. You want them sent when the form is submitted, right?

This is correct.
Why are you using links instead of buttons?

This is a stylistic call and I prefer them.
Can you show us what you've got so far?

I am sorry, my site isn't live. I would be happy to post more code if
the code I have already post isn't helping.

Thanks again for your help!
 
P

pbd22

pbd22 said the following on 5/8/2007 10:28 AM:




Why make it harder than it has to be though? If the user can associate
data with each file, you have two choices:

1) Create a text input for each file and let them type.
2) Create an array that tracks what each description is. When it is
clicked, you put that description in the textbox and let them edit. Use
the onchange event for the textbox to update the array.

Then use the onsubmit to put all the data from the array in an element
and submit it.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

Thanks Randy. Your suggestion makes sense. I'll try that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,431
Latest member
ElyseG3173

Latest Threads

Top