• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

How to insert at runtime using AJAX

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67498
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
// The function which will get called on onchange



 
Saurabh Naik
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?

 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic