943,929 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 4831
  • JSP RSS
Jun 30th, 2009
0

Adding textbox dynamically based on dropdown value

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
prasannakarthik is offline Offline
6 posts
since Jun 2009
Jun 30th, 2009
0

Re: Adding textbox dynamically based on dropdown value

Please show your code first
Reputation Points: 17
Solved Threads: 6
Posting Pro in Training
ayesha789 is offline Offline
485 posts
since Jun 2009
Jun 30th, 2009
0

Re: Adding textbox dynamically based on dropdown value

HTML code:
html Syntax (Toggle Plain Text)
  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:
JavaScript Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
prasannakarthik is offline Offline
6 posts
since Jun 2009
Jun 30th, 2009
0

Re: Adding textbox dynamically based on dropdown value

this is what you are looking for , i guess

JSP Syntax (Toggle Plain Text)
  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...
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Jul 7th, 2009
0

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...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
prasannakarthik is offline Offline
6 posts
since Jun 2009
Jul 7th, 2009
0

Re: Adding textbox dynamically based on dropdown value

@prasannakarthik
can we see the code ayesha gave you ??
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Jul 14th, 2009
0

Re: Adding textbox dynamically based on dropdown value

Reputation Points: 10
Solved Threads: 1
Newbie Poster
CoSIS1 is offline Offline
22 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: How to create tabs using jsp?
Next Thread in JSP Forum Timeline: Image Upload & Display Image





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC