
07-15-2007, 11:04 AM
|
|
Junior Member
|
|
Join Date: Jul 2007
Posts: 3
|
|
HTML form and Javascript Urgent Help needed
HI,
I just want to make a form where I have a selection list and a text box.
Now, the selection list box contains smileys like :---), :---(, ;---) etc.
What I want to do is type in text in the text box like
hello
Now if I select :---) from drop down box it should be displayed as
hello :---) in the text box
Now I should be able to continue writing in the text box
hello :---) sorry and then again select another option from drop down
like for example
hello :---) sorry :---(
These symbols (:---),:---( should come from the drop down select list)
I m using this script >
<body>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function put_it()
{
var w = document.myform.sel_list.selectedIndex;
document.myform.r_text.value =
document.myform.sel_list.options[w].text;
}
//-->
</SCRIPT>
<FORM NAME="myform">
<SELECT NAME="sel_list" onclick="put_it()" SIZE="3">
<OPTION VALUE="value1">:---)
<OPTION VALUE="value2">:---(
<OPTION VALUE="value3">;---)
<OPTION VALUE="value4">:---)
<OPTION VALUE="value5">:---(
</SELECT>
<BR>
<INPUT TYPE="TEXT" VALUE="" NAME="r_text" SIZE="20">
</FORM>
</body>
------------------------------------------------------------
The problem is that every time I select from the drop down list the text box refreshes and the typed in text is lost.
Please suggest what change shall I make to this script.
Also, I want to do same thing by having images of icons on my page and similarly when some clicks on the image the corresponding symbol like for smiling face :---) gets inserted into text box. Plzzz suggest how can I do this!...thanks a ton
Please reply sooon!
|