| Author |
add values in select option using ajax and servlet
|
Vaishali Paramane
Ranch Hand
Joined: Mar 05, 2007
Posts: 106
|
|
Hi
I want to add values in select option depends of select values of other select option.
Front view I am using jsp and backend servlet
I can able to display values in textHint but I want to add these values in start_date select option.
Can anyone help me?
Thanks
Vaishali
|
SCJP, SCJD
Preparing for SCWCD
|
 |
amit punekar
Ranch Hand
Joined: May 14, 2004
Posts: 488
|
|
Hello,
Give the "id" for start date and access it within your Javascript that fetches the values using Ajax. Once you get access to the drop down you can add values to it.
You should use Java script framework such as jQuery and its API documentation will help you to do this.
Regards,
Amit
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
You can not set the innerHTML of a select element in IE.
Easiest solution is to use jQuery since it handles it for you.
BUT if you can not use that library, I wrote a little function that tries to set the innerHTML. If setting the innerHTML results in no options being added, it rewrites the function so it will create an element and clone its options.
Running Example: http://jsbin.com/uqera4/
Eric>
|
 |
Vaishali Paramane
Ranch Hand
Joined: Mar 05, 2007
Posts: 106
|
|
thanks Eric, but still its not working
I changed code
document.getElementById("txtHint").innerHTML=dateArray;
line instead of arrays i am getting output as [object]
I am very new in ajax, javascript.
Can anyone help me?
Thanks
Vaishali
|
 |
 |
|
|
subject: add values in select option using ajax and servlet
|
|
|