DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   JSP (http://www.daniweb.com/forums/forum24.html)
-   -   Adding textbox dynamically based on dropdown value (http://www.daniweb.com/forums/thread200623.html)

prasannakarthik Jun 30th, 2009 4:31 am
Adding textbox dynamically based on dropdown value
 
Hi,
I like to add textbox based on the user selection in drop down box,I have used an function to do that but its not workin,also i like to append the selected value(from drop down) to the input from the text box.

Cheers!
lpk

ayesha789 Jun 30th, 2009 8:27 am
Re: Adding textbox dynamically based on dropdown value
 
Please show your code first

prasannakarthik Jun 30th, 2009 8:54 am
Re: Adding textbox dynamically based on dropdown value
 
HTML code:
<td><select name=select1 id="Expertise" name="Expertise" onChange=checkForm(document.form1.select1)> 
                    <option>Trained</option>
                    <option>ProjectExp</option>
                    <option>Certified</option>
                    <option>ProjectExp & Certified</option></select>
                    </td>
SCRIPT:
function checkForm(type) {      
    var a=type.selectedIndex
    if(a==1)
{//code to add text fields
}
 
}

aashishn86 Jun 30th, 2009 10:55 am
Re: Adding textbox dynamically based on dropdown value
 
this is what you are looking for , i guess

<html>
<head>
</head>
<script type="text/javascript">
function showdv(obj,id1,id2)
{

txt=obj.options[obj.selectedIndex].text;
document.getElementById("box").style.display='none';

if(txt.match(id1))
{
document.getElementById("box").style.display='block';
document.getElementById("boxx").value=txt
}

if(txt.match(id2))
{
document.getElementById("box").style.display='block';
document.getElementById("boxx").value=txt
}


}
</script>

<body>

<thead>
<select id="opts" onchange="showdv(this,'one','two');" >
<option value="">select</option>
<option value="one">one</option>
<option value="two">two</option>
</select>
</thead>

<div id="box" style="display:none;">                       
<input Type="text" id="boxx"  maxlength="20" >
</div>

</body>
</html>

hope it helps...

prasannakarthik Jul 7th, 2009 2:24 am
Re: Adding textbox dynamically based on dropdown value
 
Hi ayesha,
The code you have given works great..But when i make some changes,i got struck with it...
Actually i will be having multiple drop down boxes(no's decided dynamcially)when i select 1 and 2 a text should appear near to the drop down..

Can you help me out in this...

aashishn86 Jul 7th, 2009 6:28 am
Re: Adding textbox dynamically based on dropdown value
 
@prasannakarthik
can we see the code ayesha gave you ??

CoSIS1 Jul 14th, 2009 3:55 am
Re: Adding textbox dynamically based on dropdown value
 
ajax
take a look
http://www.daniweb.com/forums/thread197237.html


All times are GMT -4. The time now is 1:52 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC