File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to insert at runtime using AJAX

 
Saurabh Naik
Ranch Hand
Posts: 87
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose I have combobox of Countries.. and second combo box of Cities.. ..
when I select Country the Cities get displayed according to it !! My program is running fine..
but when I select country from one combo box the second combo box appears at that time ... I have written code on onchange() event !

my problem is.. two combo box must appear on page..and when I select country from one combo box.. the second combo box should be filled..

so how to overcome this difficulty ?

I have written code in JSP (<select><option></option></select>) and in html I have used div tag to insert combo box at runtime..

I have to write that code in my main html and not in jsp..and want to just insert the data on onchange event !

my another problem is .. when I use document.myform.getElementById("cities").. this code does not work

and documen.getElementById("cities") this works perfectlyy

Thanks in Advance
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saurabh Naik wrote: suppose I have combobox of Countries..
Firstly, please be sure to use proper terms to avoid confusion. There is no such thing as a "Combo Box" in HTML. Please read this for more information.

Secondly, I'm not sure exactly what you are asking. Are you having trouble creating an empty second select element to be filled in later?

And,
my another problem is .. when I use document.myform.getElementById("cities").. this code does not work

Of course not. The form has no such method. Why would you think it would?

and documen.getElementById("cities") this works perfectlyy

Really? "documen"? Please be careful when posting code to the forums that it does not contain mistakes like this.
 
Steve James
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
// The function which will get called on onchange



 
Saurabh Naik
Ranch Hand
Posts: 87
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry for my mistakes.

and document.myform.mydiv.value .. does not work... div tag doesn't have attribute called name.

I am inserting div tag in the select tag ... <select><div id="mydiv"></div></select>

and in JSP I am writing <option> tags.. but it is not working.....

but if I write in JSP <select> and <option> tag it works perfectly... but it occurs on html on onchange event...

so how to solve this problem
 
Steve James
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am inserting div tag in the select tag ... <select><div id="mydiv"></div></select>


just guessing div visible and hidden problems ?

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You really should not be using document.myForm.getElementById. You should just use document.getElementById().

When you say it does not work, are you getting an error message? Have you used a tool such as Firebug or Web Developer Toolbar to look at the source code after it runs?

Eric
 
Saurabh Naik
Ranch Hand
Posts: 87
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No its not giving me any kind of error messege. I am not using any kind of tool for doing it !

and even I am thinking that div tag get hide in select tag. thats why its not showing ...

It runs with document.getElementById() method.. but again If I use directly div tag without select tag in html file it runs fine

but if I use select tag in html file and in that div tag.. so I can give opting tag through calling function.. it does not work.

any solution ?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic