answersLogoWhite

0


Best Answer

The best way to add a test box based on an option chosen from a select box is to modify the DOM to show the element. You can accomplish this by adding the text box to the DOM when the option is selected, or by having it already there, but hidden, until the option is selected.

Here is some sample code to show the text box only when Option 7 is chosen. Feel free to modify it to suit your needs:

<select onchange="if (this.value 7) { document.getElementById('textbox1').display = 'inline'; } else { document.getElementById('textbox1').display = 'none'; }">

<input type="text" id="textbox1" name="textbox1" style="display: none;">

Both of these methods can also be used by creating a JavaScript function to handle the actual procedure, and the onchange attribute can simply call that function. You can use arguments to the function to encapsulate and reuse the code for other elements on your page.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you add textbox when options is selected using javascript?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you create textbox using javascript?

Im not sure as to what your exactly asking, but If you go to www.w3schools.com/js/default.asp you will find what you are looking for.


Can you use an ASP textbox using PHP?

No


How do you insert value to a dropdownlist from textbox input php?

Store the textbox input in a database using a html form prefarably. Using a loop get all the textbox input from database and use print/echo to show them in a dropdown.


How do you enable javascript in your web browser using IE and Mozilla Firefox?

There isn't a way to enable or disable JavaScript in IE8 or IE7. In Firefox, you go to Tools &gt; Options &gt; Content &gt; and check the box that says Enable JavaScript then click OK. Other IE's might have javascript, I don't know how to enable javascript for IE, this might be hard to know...


How do you check length of password using javascript?

Use the length property of string in javascript.


How do you change the input language of a textbox from English to Hindi using PHP?

Changing the input language of a textbox from English to Hindi in PHP involves setting the lang attribute to &quot;hi&quot; in the input tag. This informs the browser that the expected language of the entered text should be Hindi. Additionally, you can utilize JavaScript to provide a virtual Hindi keyboard for users to input text easily in Hindi.


1. Spreadsheet table created dynamically at run-time2. Numeric row number labels and alphabetical column labels (10 x 10)3. Ability to enter numbers into the spreadsheet using the single textbox?

bruh


What is the correct HTML for making a a text input field?

the Answer is To make a text input field, you can useor.The input-element will only make a single text line. What you are most likely looking for is textarea:You can adjust the text area's size using the attributes rows="" and columns=""The input text can be handled using the onclick="" attribute and JavaScript or, if the textarea is inside a form, through PHP.


Do you need java script when playing games and how to you add it to my browser?

Most online games on browser are developed using flash and shockwave player files. So you do not require javascript for them. But in case they use javascript it is not a worry. Most popular browsers support javascript. Just look on the search engine how to enable javascript. For eg. Mozilla Firefox you just just click on Tools in Menu Bar and then go to Options and click on the tab Content. There should be a checkbox to enable javascript


Can you get ipaddress by using javascript?

No, use asp


How do you show the text box output in the browser using Ajax code?

You can directly do that in the JavaScript. Just get the value of the input type in JavaScript using id and show it using .innerHTML.


What are the benefits of using JavaScript for forms?

JavaScript can help with dynamic retrieval of form data using AJAX and also the data can be checked and validated before sending it to the server. Apart from that you could add some animation and change views using javascript and jquery.