Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

add values in select option using ajax and servlet

 
Vaishali Paramane
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic