why are you creating a textnode? just grab the text from the text area,
append the new word and update the textarea? (just a guess actually I've
never tried to do what you are doing...
with prototype it might be as easy as<select
onchange($('target_textarea_id').value = $('target_textarea_id').value +
this.value)
but i'm not a JS expert and I only started on pt this week..
On 8/24/07, Mike Stramba <[EMAIL PROTECTED]> wrote:
>
>
> I have a simple form at http://mstramba.com/fb5.html
>
> It's just a <select> and a textarea.
>
> The idea is to be able to either type into a text area directly or
> choose from a list of saved words in the select box. When a new choice
> is made from the select, it automatically gets inserted into the text
> area.
>
> This code DOES work in I.E6 (on my machine (XP pro), but doesn't work
> in Firefox 2.0.0.4 or Opera 9.0.2
>
> With Firefox 2.0.04, when the page is first loaded, I can choose from
> the select control and it works until I type something in the text
> area, and then it stops working.
> (the <select> is not sending to the text area anymore)
>
> With Opera 9.02, the select control doesn't work at all.
>
> 1) Does prototype do anything "internally" differently for whatever
> it's equivalent of
>
> var txtNode=document.createTextNode(selectValue);
> var textArea=document.getElementById(targetTextArea);
> textArea.appendChild(txtNode);
>
> is ?
>
> 2) Should I be using some other way of accessing the textarea other
> than the "appendChild" method?
>
> Any other ideas appreciated.
>
> Mike
>
>
> ============================== http://snippets.dzone.com/posts/show/4465
> =======
> This code DOES work in I.E6 (on my machine (XP pro), but doesn't work
> in Firefox 1.5.0.12 or Opera 9.0.2
>
> The idea is to be able to either type into a text area directly or
> choose from a list of saved words in the select box. When a new choice
> is made from the select, it automatically gets inserted into the text
> area.
>
> With Firefox 2.0.0.4, when the page is first loaded, I can choose from
> the select control and it works until I type something in the text
> area, and then it stops working.
>
> With Opera 9.02, the select control doesn't work at all.
>
> IE6, works fine.
>
> // When the <select> is changed it should send the current
> select.value
> // to a given texarea (id='content' in this case)
>
> // The user can also just type directly into the textarea, the idea
> being that
> // the <select> gives access to a stored list of words. Actually the
> practical
> // use I'm trying to make of it is to hook it into the 'Instiki'
> R.O.R. wiki
>
> //
> // With FireFox 2.0.04, this is working UNTIL something is manually
> typed into
> // the text area, then it stops working.
> //
>
> // It DOES work with IE6.
>
> //
> // It doesn't work with Opera 9.0.2
> //
>
> function SendSelectValueToTextArea(selectValue,targetTextArea)
> {
> var txtNode=document.createTextNode(selectValue);
> var textArea=document.getElementById(targetTextArea);
> textArea.appendChild(txtNode);
> }
>
> <select onchange="SendSelectValueToTextArea(this.value,'content')
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---