Adding textbox dynamically based on dropdown value

Reply

Join Date: Jun 2009
Posts: 3
Reputation: prasannakarthik is an unknown quantity at this point 
Solved Threads: 0
prasannakarthik prasannakarthik is offline Offline
Newbie Poster

Adding textbox dynamically based on dropdown value

 
0
  #1
Jun 30th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 197
Reputation: ayesha789 is an unknown quantity at this point 
Solved Threads: 3
ayesha789's Avatar
ayesha789 ayesha789 is offline Offline
Junior Poster

Re: Adding textbox dynamically based on dropdown value

 
0
  #2
Jun 30th, 2009
Please show your code first
Ayesha
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 3
Reputation: prasannakarthik is an unknown quantity at this point 
Solved Threads: 0
prasannakarthik prasannakarthik is offline Offline
Newbie Poster

Re: Adding textbox dynamically based on dropdown value

 
0
  #3
Jun 30th, 2009
HTML code:
  1. <td><select name=select1 id="Expertise" name="Expertise" onChange=checkForm(document.form1.select1)>
  2. <option>Trained</option>
  3. <option>ProjectExp</option>
  4. <option>Certified</option>
  5. <option>ProjectExp & Certified</option></select>
  6. </td>
SCRIPT:
  1. function checkForm(type) {
  2. var a=type.selectedIndex
  3. if(a==1)
  4. {//code to add text fields
  5. }
  6.  
  7. }
Last edited by peter_budo; Jun 30th, 2009 at 1:51 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

Re: Adding textbox dynamically based on dropdown value

 
0
  #4
Jun 30th, 2009
this is what you are looking for , i guess

  1. <html>
  2. <head>
  3. </head>
  4. <script type="text/javascript">
  5. function showdv(obj,id1,id2)
  6. {
  7.  
  8. txt=obj.options[obj.selectedIndex].text;
  9. document.getElementById("box").style.display='none';
  10.  
  11. if(txt.match(id1))
  12. {
  13. document.getElementById("box").style.display='block';
  14. document.getElementById("boxx").value=txt
  15. }
  16.  
  17. if(txt.match(id2))
  18. {
  19. document.getElementById("box").style.display='block';
  20. document.getElementById("boxx").value=txt
  21. }
  22.  
  23.  
  24. }
  25. </script>
  26.  
  27. <body>
  28.  
  29. <thead>
  30. <select id="opts" onchange="showdv(this,'one','two');" >
  31. <option value="">select</option>
  32. <option value="one">one</option>
  33. <option value="two">two</option>
  34. </select>
  35. </thead>
  36.  
  37. <div id="box" style="display:none;">
  38. <input Type="text" id="boxx" maxlength="20" >
  39. </div>
  40.  
  41. </body>
  42. </html>

hope it helps...
rEaLITy iS aN iLLUSIOn cAUSED bY lACk oF aLCOHOL....
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 3
Reputation: prasannakarthik is an unknown quantity at this point 
Solved Threads: 0
prasannakarthik prasannakarthik is offline Offline
Newbie Poster

Re: Adding textbox dynamically based on dropdown value

 
0
  #5
Jul 7th, 2009
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...
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

Re: Adding textbox dynamically based on dropdown value

 
0
  #6
Jul 7th, 2009
@prasannakarthik
can we see the code ayesha gave you ??
rEaLITy iS aN iLLUSIOn cAUSED bY lACk oF aLCOHOL....
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 22
Reputation: CoSIS1 is an unknown quantity at this point 
Solved Threads: 1
CoSIS1 CoSIS1 is offline Offline
Newbie Poster

Re: Adding textbox dynamically based on dropdown value

 
0
  #7
Jul 14th, 2009
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC