| Author |
How to insert at runtime using AJAX
|
Saurabh Naik
Ranch Hand
Joined: Apr 24, 2008
Posts: 87
|
|
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
|
SCJP 6 (88%), SCWCD 5 (78%), preparing for SCBCD
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
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.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Steve James
Ranch Hand
Joined: Apr 12, 2009
Posts: 44
|
|
// The function which will get called on onchange
|
I am just a brick in the wall of Java
|
 |
Saurabh Naik
Ranch Hand
Joined: Apr 24, 2008
Posts: 87
|
|
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
Joined: Apr 12, 2009
Posts: 44
|
|
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
Joined: Nov 08, 2001
Posts: 15357
|
|
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
Joined: Apr 24, 2008
Posts: 87
|
|
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 ?
|
 |
 |
|
|
subject: How to insert at runtime using AJAX
|
|
|