| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to keep contents of textbox on click
Hello to everyone.
I'm in need of some help regarding this problem. I've created a form that contains 2 dependent drop down menus a button and a text box. What happens is that once the user selects some stuff from both drop downs and hits the button the contents of the drop down menus get copied in the text box. So far so good. The fact is that if the user makes a second selection in the drop downs and re-clicks thw button the new contents of the drop downs replace the old ones in the text box. Instead what I would like to do is simply add the new contents in the text box without deleting anything The code for copying the drop downs in the textbox is this: <script> oldvalue = ""; function passText(passedvalue) { if (passedvalue != "") { var temp2 = document.allproducts.selList1.options[document.allproducts.selList1.selectedIndex].text var temp3 = document.allproducts.selList2.options[document.allproducts.selList2.selectedIndex].text var totalvalue = passedvalue+"\n"+oldvalue; temp2= "Κατηγορία: " + temp2 + "\nΠροϊόν: " + temp3 + "\n\n"; document.allproducts.Notes.value = temp2 // document.displayform.itemsbox.value = totalvalue; oldvalue = document.allproducts.Notes.value; } } // End --> </script> The code for the button once clicked is this: onClick="MM_callJS('passText(this.allproducts.selList1.opti ons[this.allproducts.selList1.selectedIndex].value)')" value="Add to text box"> I hope somebody can give me a hand here 'cause I'm really stuck for long. Thank you and bye! |
|
#2
|
||||
|
||||
|
Try this:
document.allproducts.Notes.value += temp2 or document.allproducts.Notes.value = document.allproducts.Notes.value & temp2 Also: The line oldvalue = document.allproducts.Notes.value; should be placed after the line temp2= "Κατηγορία: " + temp2 + "\nΠροϊόν: " + temp3 + "\n\n"; so that you don't lose the old value. I hope this works D... . . . var totalvalue = passedvalue+"\n"+oldvalue; temp2= "Κατηγορία: " + temp2 + "\nΠροϊόν: " + temp3 + "\n\n"; document.allproducts.Notes.value = temp2 // document.displayform.itemsbox.value = totalvalue; oldvalue = document.allproducts.Notes.value; . . . |
|
#3
|
|||
|
|||
|
musa I really don't know how to thank you.
IT WORKS!!!!!!!!!!! The solution was so obvious that only a newbie like me would have had a problem here. I had thought of everything else (pass the function to an array e.t.c) but this. Thanks a thousand for your precious help and sorry for making your work even harder (I just saw that I left some categorie's names in greek. Sorry about that) Bye, take care and once more THANK YOU!!!!!!! |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > How to keep contents of textbox on click |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|