•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,423 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,609 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 3999 | Replies: 5
![]() |
hi every1
i m using jsp in jbuilder9 to create a website
i have 2 drop down button
a1 and b1
when i select a option in a1 the values of b1 comes
if i change the value of a1 then the value of b1 also changes.
then i have a button to dynamically add 2 similar drop downs
i click the button.
the drop down are added
a2 and b2
but the problem is
when i select some thing in a2 the value of b1 changes instead of b2.
i m not getting the solution.
plz if any 1 can help me out.
thanks in advance
regards
Bhuvan
i m using jsp in jbuilder9 to create a website
i have 2 drop down button
a1 and b1
when i select a option in a1 the values of b1 comes
if i change the value of a1 then the value of b1 also changes.
then i have a button to dynamically add 2 similar drop downs
i click the button.
the drop down are added
a2 and b2
but the problem is
when i select some thing in a2 the value of b1 changes instead of b2.
i m not getting the solution.
plz if any 1 can help me out.
thanks in advance
regards
Bhuvan
Last edited by bhuvan83 : Mar 8th, 2007 at 8:12 am.
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation:
Rep Power: 19
Solved Threads: 200
•
•
Join Date: Oct 2006
Location: Sofia, Bulgaria
Posts: 181
Reputation:
Rep Power: 3
Solved Threads: 10
It looks like your buttons A2 and B2 copy exactly the code you used to create a1 and b1. Use an iteration to change id and names of the dynamically added buttons, so that your b button become b2, not b1.
it should look something like this
var iteration = lastButtonNameNumber + 1;
var new_a_ButtonName = 'a' + iteration;
var new_b_ButtonName = 'b' + iteration;
And then access the new b-button value using something like
document.form.new_b_ButtonName.value = ....
Hope you can figure it out by yourself.
Good luck.
" Of all the things I've lost,
I miss my mind the most...."
Mark Twain
I miss my mind the most...."
Mark Twain
c if there r any error in th code n reply.<br>
this is the code i m using to create the drop boxes dynamically.<br>
var i=0;
var option=new Array();
function insRow(){
var d=document.getElementById("div");
d.innerHTML+="<select id='D"+i+"' class='input' onChange='getSh(this.selectedIndex)'><option>Select Here</option>"+
<%
rs=st.executeQuery("select * from productTab");
while(rs.next())
{
%>
"<option><%=rs.getString("productName")%></option>"+
<%}%>
"</select>"
d.innerHTML+="<select name='DD"+i+"' id='DD"+i+"' class='input'><option>Select Here</option></select>"
d.innerHTML+="<select name='DDD+i' id='DDD+i' class='input'><option>Select Here</option></select>"
d.innerHTML+="<input type=text name='T+i' id='T+i' class='input-time'><br>"
option +=["DD"+i];
option +=["D"+i];
i++;
}
function getSh(selectedcitygroup)
{
document.getElementById("DD+i").options.length=1
if(selectedcitygroup>0){
for(i=0;i<cities[selectedcitygroup].length; i++)
document.getElementById("DD+i").options[document.getElementById("DD+i").options.length]=new Option(cities[selectedcitygroup][i].split("|")[0], cities[selectedcitygroup][i].split("|")[1])
}
}
this is the code i m using to create the drop boxes dynamically.<br>
var i=0;
var option=new Array();
function insRow(){
var d=document.getElementById("div");
d.innerHTML+="<select id='D"+i+"' class='input' onChange='getSh(this.selectedIndex)'><option>Select Here</option>"+
<%
rs=st.executeQuery("select * from productTab");
while(rs.next())
{
%>
"<option><%=rs.getString("productName")%></option>"+
<%}%>
"</select>"
d.innerHTML+="<select name='DD"+i+"' id='DD"+i+"' class='input'><option>Select Here</option></select>"
d.innerHTML+="<select name='DDD+i' id='DDD+i' class='input'><option>Select Here</option></select>"
d.innerHTML+="<input type=text name='T+i' id='T+i' class='input-time'><br>"
option +=["DD"+i];
option +=["D"+i];
i++;
}
function getSh(selectedcitygroup)
{
document.getElementById("DD+i").options.length=1
if(selectedcitygroup>0){
for(i=0;i<cities[selectedcitygroup].length; i++)
document.getElementById("DD+i").options[document.getElementById("DD+i").options.length]=new Option(cities[selectedcitygroup][i].split("|")[0], cities[selectedcitygroup][i].split("|")[1])
}
}
Last edited by bhuvan83 : Mar 12th, 2007 at 5:57 am.
Bhuvan Aggarwal
There is no word impossible.
its i m possible
There is no word impossible.
its i m possible
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- JavaScript/DHTML newbie -- general questions (JavaScript / DHTML / AJAX)
- converting from javascript to HTML? (Java)
- Does google understand javascript? (Search Engine Optimization)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: My Javascript won't work...
- Next Thread: Javascript won't work... :(



Linear Mode