javascript - TypeError: d.textarea1 is undefined , d.textarea1.value = sChoices; -
hi have javascript code when click qualities want on select dropdown list display textarea. got error typeerror: d.textarea1 undefined d.textarea1.value = schoices;
is there wrong in code?
<!doctype html> <html> <head> <title>list box 4 example</title> <script type="text/javascript"> function tellme(d){ var schoices =""; for(i=0; i<d.listbox.options.length; i++){ if(d.listbox.options[i].selected == true){ schoices += d.listbox.options[i].text +"\n"; } } d.textarea1.value = schoices; } </script> </head> <body bgcolor="lightgreen"> <form name="form1"> <p>girl's quaalities want?</p> <select name="listbox" onchange="tellme(this.form)" multiple> <option>pretty</option> <option>sexy</option> <option>hot</option> <option>intelligent</option> <option>funny</option> </select> </form> <br /> choose:<br /> <textarea rows="4" cols="20" name="textarea1"></textarea> </body> </html>
any muchly appreciated! thanks
the textarea not in form therefore not able reference form elements, add form.
<form name="form1"> <p>girl's quaalities want?</p> <select name="listbox" onchange="tellme(this.form)" multiple> <option>pretty</option> <option>sexy</option> <option>hot</option> <option>intelligent</option> <option>funny</option> </select> <br /> choose:<br /> <textarea rows="4" cols="20" name="textarea1"></textarea> </form>
Comments
Post a Comment