simple question

A

AlBen

Hello

sorry I don't know about javascript but I have to finish my work and
there I have some scripts

on my page I have a textarea form and a select form
when a user click in the select form I need the text of the selection
apears in my textare form
that's all

Could you give me the shortest way to do that?
Thank you to all of you.


<textarea rows="4" name="S1" cols="48"></textarea>

<select size="6" name="D1" id="fname" onchange="???">
<option>DELETE</option>
<option>INSERT</option>
<option>UPDATE</option>
</select>
 
D

David Mark

Hello

sorry I don't know about javascript but I have to finish my work and
there I have some scripts

The person who should (and likely will) be sorry is the one who
assigned JavaScript-related work to someone who doesn't know about
JavaScript.
on my page I have a textarea form and a select form

Apparently you don't know about HTML either. Those are input
elements, not forms.
when a user click in the select form I need the text of the selection
apears in my textare form
that's all

Could you give me the shortest way to do that?
Thank you to all of you.

<textarea rows="4" name="S1" cols="48"></textarea>

<select size="6" name="D1" id="fname" onchange="???">
<option>DELETE</option>
<option>INSERT</option>
<option>UPDATE</option>
</select>

this.form.elements.S1.value = this.options[this.selectedIndex].text;
 
T

Thomas 'PointedEars' Lahn

AlBen said:
on my page I have a textarea form and a select form
when a user click in the select form I need the text of the selection
apears in my textare form

A(n HTML) form *consists of* form _controls_ (not forms), which e.g.
`textarea' and `select' elements are.
that's all

Could you give me the shortest way to do that?
[...]

<form action="..." ...>
...

<textarea rows="4" name="S1" cols="48"></textarea>

<select size="6" ...
onclick="this.form.elements['S1'].value += this.value;">
<option>DELETE</option>
<option>INSERT</option>
<option>UPDATE</option>
</select>

...
</form>

RTFM. RTFFAQ. http://jibbering.com/faq/


PointedEars
 
D

David Mark

AlBen said:
on my page I have a textarea form and a select form
when a user click in the select form I need the text of the selection
apears in my textare form

A(n HTML) form *consists of* form _controls_ (not forms), which e.g.
`textarea' and `select' elements are.
that's all
Could you give me the shortest way to do that?
[...]

<form action="..." ...>
...

<textarea rows="4" name="S1" cols="48"></textarea>

<select size="6" ...
onclick="this.form.elements['S1'].value += this.value;">

The change event would be more appropriate (and accessible.)
 
B

Bart Van der Donck

Thomas said:
<form action="..." ...>
...

<textarea rows="4" name="S1" cols="48"></textarea>

<select size="6" ...
onclick="this.form.elements['S1'].value += this.value;">
<option>DELETE</option>
<option>INSERT</option>
<option>UPDATE</option>
</select>

Individual options should preferably be approached by "selectedIndex"
rather than "value".
 
B

Bart Van der Donck

[...]
onclick="this.form.elements['S1'].value += this.value;">

This instruction doesn't make the text of the selected option appear
in the textarea. It just keeps the current value of the textarea, and
adds the text of the selected option at the end of it.
 
A

AlBen

Thank you guys!

Only, I would like to ask David Mark about one thing.
The most important in our life is to Keep Our Feet On The GROUND!!!
What dou you think David?
 
T

Thomas 'PointedEars' Lahn

Randy said:
Thomas 'PointedEars' Lahn said the following on 10/16/2007 5:24 AM:
<select size="6" ...
onclick="this.form.elements['S1'].value += this.value;">
<option>DELETE</option>

onchange="alert(this.value)" and test it in IE......

<form action="..." ...>
...

<textarea rows="4" name="S1" cols="48"></textarea>

<select size="6" ...
onclick="this.form.elements['S1'].value +=
this.options[this.selectedIndex].text + ' ';">
<option>DELETE</option>
<option>INSERT</option>
<option>UPDATE</option>
</select>

...
</form>

The trailing space is only appended here because this looks like an SQL
statement builder. Evaluating the text cursor position to make this a
statement editor is left as an exercise to the reader.


PointedEars
 
D

David Mark

Thank you guys!

Only, I would like to ask David Mark about one thing.
The most important in our life is to Keep Our Feet On The GROUND!!!
What dou you think David?

About what?
 
T

Thomas 'PointedEars' Lahn

Randy said:
Thomas 'PointedEars' Lahn said the following on 10/16/2007 5:39 PM:
Randy said:
Thomas 'PointedEars' Lahn said the following on 10/16/2007 5:24 AM:
<select size="6" ...
onclick="this.form.elements['S1'].value += this.value;">
<option>DELETE</option>
onchange="alert(this.value)" and test it in IE......
<form action="..." ...>
...

<textarea rows="4" name="S1" cols="48"></textarea>

<select size="6" ...
onclick="this.form.elements['S1'].value +=
this.options[this.selectedIndex].text + ' ';">
<option>DELETE</option>
<option>INSERT</option>
<option>UPDATE</option>
</select>

...
</form>

Still a dumb way to do it.
IBTD.

Simply give the OPTION a value and be done with it....... Might even make
it easier to get the *value* of the select element on the server if/when
the form is submitted.

The reason I did not propose to use the `value' attribute here is that I am
quite certain that this form will never be submitted; at least the `select'
control would not need to (and so would not need a name, BTW). And then,
provided that the `value' property of the `select' would be as compatible as
it needs to be, the advantage of slightly faster property access with that
property would not outweigh the disadvantage of having to maintain attribute
value *and* element content per each option.


PointedEars
 
A

AlBen

WOW men ! ))))
This is really a surprise that a "simple question" can generate a GOOD
discussion.
I'm a developer in win32 env. during the last 12 years and every time
surprised that a javascript can give so much headache for people who
develop with.

For David re-read you first comment and try to understand that I/WE
don't need such an answer in this forum. Sorry.
 
T

The Natural Philosopher

AlBen said:
WOW men ! ))))
This is really a surprise that a "simple question" can generate a GOOD
discussion.
I'm a developer in win32 env. during the last 12 years and every time
surprised that a javascript can give so much headache for people who
develop with.

Its cos its a crap language with the worst features of three or four
thrown together, probably by a computer scientist.


Makes you long for COBOL - a langauge designed so that any Navy Grunt
could more or less with attention to detail, write a program..
 
D

David Mark

WOW men ! ))))
This is really a surprise that a "simple question" can generate a GOOD
discussion.
I'm a developer in win32 env. during the last 12 years and every time
surprised that a javascript can give so much headache for people who
develop with.

For David re-read you first comment and try to understand that I/WE
don't need such an answer in this forum.

You mean the one where I answered your question? If you didn't want
an answer, then perhaps you shouldn't have posted a question.

And if you don't know script and/or HTML, perhaps you shouldn't be
scripting Web pages.
 
A

AlBen

You mean the one where I answered your question? If you didn't want
an answer, then perhaps you shouldn't have posted a question.

And if you don't know script and/or HTML, perhaps you shouldn't be
scripting Web pages.

Occasionally In IT we all doing things in what we are not good.
Not true?

But I don't need at all that a ..... ...... like you remind me a thing
that is evident.
That's all.
Have a good day.
 
D

David Mark

Occasionally In IT we all doing things in what we are not good.
Not true?

Not in a well-managed IT department. Why would you assign a scripting
task to someone who lacks basic knowledge about scripting?
 

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,150
Messages
2,570,853
Members
47,394
Latest member
Olekdev

Latest Threads

Top