javascript dropdownlist

javascript dropdownlist

I want to replace window.prompt with a textbox but it doesnt work,please help.

<script>
function addOption(Area){
oc = Area.options.length;
if(Area.selectedIndex==oc-1){
   newOpt = window.prompt("Enter Area","");
   if(newOpt+"">""){
     Area.options[oc] = new Option(Area.options[oc-1].text);
     Area.options[oc-1] = new Option(newOpt, newOpt, true, true);
   }
}
}
</script>
//dropdownlist
<select name="Area" id="Area" onchange="addOption(this)">
              <option value="Please Select">Please Select</option>
              <option value="Johannesburg">Johannesburg</option>
              <option value="Pretoria">Pretoria</option>
              <option value="Cape Town">Cape Town</option>
              <option value="Durban">Durban</option>
              <option value="Other Specify">Other Specify</option>
            </select>
View Answers

May 31, 2011 at 11:16 AM

<html>
<script>
function show(){
oc = Area.options.length;
if(Area.selectedIndex==oc-1){
document.getElementById('lab').style.visibility="visible";
document.getElementById('val').style.visibility="visible";
document.getElementById('b').style.visibility="visible";
   }
}
function addOption(){
oc = Area.options.length;
newOpt = document.getElementById('val').value;
Area.options[oc] = new Option(Area.options[oc-1].text);
Area.options[oc-1] = new Option(newOpt, newOpt, true, true);
document.getElementById('lab').style.visibility="hidden";
document.getElementById('val').style.visibility="hidden";
document.getElementById('b').style.visibility="hidden";
   }
</script>
<select name="Area" id="Area" onchange="show()">

              <option value="Please Select">Please Select</option>
              <option value="Johannesburg">Johannesburg</option>
              <option value="Pretoria">Pretoria</option>
              <option value="Cape Town">Cape Town</option>
              <option value="Durban">Durban</option>
              <option value="Other Specify">Other Specify</option>

            </select>
            <br><br>
            <label id="lab" style="visibility:hidden;">Enter Area</label><input style="visibility:hidden;" type="text" id="val" ><input type="button" id="b" style="visibility:hidden;" value="ok" onclick="addOption();">
</html>









Related Tutorials/Questions & Answers:
javascript dropdownlist
javascript dropdownlist  I want to replace window.prompt with a textbox but it doesnt work,please help. <script> function addOption(Area..., newOpt, true, true); } } } </script> //dropdownlist <select name
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
Advertisements
DropDownList in Flex4
DropDownList control in Flex4: The DropDownList control contains a drop-down... to that of the SELECT form element in HTML. The DropDownList control consists... provide the data to the DropDownList control by using the DataProvider(<s
JavaScript
JavaScript  clone JavaScript
how to get data using dropdownlist, textbox and search button in jsp
how to get data using dropdownlist, textbox and search button in jsp  Hi, I want to display data using jsp,javascript and mysql. My Q. is If i select an entry suppose 'title' from dropdownlist and give a title name 'partial dif
javascript
javascript  javascript code to dynamically add table on button click.../javascript/javascriptexamples/javascript-add-row-dynamically.shtml http://www.roseindia.net/javascript/javascript-add-row-to-table.shtml http://www.roseindia.net
html dropdownlist code - JSP-Servlet
html dropdownlist code  hi how to get textfield in html when i select the option others in the dropdown list, pls provide the code?   Hi Friend, Try the following code: function show(){ var op
Javascript
Javascript  How validations are done using javascript ,with example? and interview questions on javASCRIPT
JavaScript
should use JavaScript? Thanks   Hi, JavaScript is scripting language that runs on browser. You have to embed JavaScript in HTML page. Please see JavaScript tutorial. Thanks
JavaScript
JavaScript  how to get full path of a file type in javascript
javascript
javascript  Hi deepak, how to write form validation on javascript
javascript
javascript  write a program to display implement about browsers using javascript
javaScript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
javascript
javascript  i have just learned javascript... can you tell me what kind of applications can be made by javascript?? thank you
javascript
javascript  how to set the request or session attribute in javascript head part of jsp page
javascript
javascript  Hi sir, This is sinduri, i want to learn javascript, so plz can u help me.how to learn
javascript
javascript  hi sir, if i want to learn javascript. what concepts i want to know
JAVASCRIPT
JAVASCRIPT  I have one textbox and I want to validate that it must start with number(1-0). can anyone tell me a javascript for that ? thanks in advance
Javascript
Javascript   Javascript to check Numeric entry in checkbox.....   Hi Please find the following code for numeric entry validation in javascript function validateBox(){ var data=document.myForm.someText.value
javascript
javascript  hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox
javaScript
javaScript  . Print a table like below in JAVASCRIPT 5 x 1 = 5 5 x 2 = 10 ΓΆβ?¬Β¦ΓΆβ?¬Β¦ΓΆβ?¬Β¦. 5 x 20 = 100
javascript
javascript  passing javascript values to jsp   Hi Friend, Try the following code:ADS_TO_REPLACE_1 form.jsp: <html> <script>... Javascript value In JSP"> <% String st=request.getParameter("msg"); if(st
Javascript
this format xxx-xxx-xxxx, i want the code in javascript. as a function.   Javascript Phone Number Validation <html> <script> function..." method="post" onsubmit="javascript:return validate();"> Phone Number:<
Javascript
Javascript  Dear Sir, Thank You a lot for your continuos support.Again i am in need of your help. What is the javascript code to disable a link,once... javascript or css Please help me.Urgent Regards Debasis   Hello Friend
Javascript
Javascript  <html> <head> <script type="text/javascript"> function validateForm() { var sname=document.getElementById('spocname'); var scontact=document.getElementById('spoccontact'); if(sname.value.length
javascript
javascript
javascript  how to create random question using javascript?   <html> <script> function displayQuestions() { document.getElementById("text").value=" "; var Questions = new Array(20
javascript
javascript
javascript  Hi deepak, sample example on javascript form validation   <html> <script> function checkName(text) { if(isNaN(text)){ return 1; } else{ alert("Please enter a valid name. The only charachters
javascript validation
javascript validation  i have 4 buttons in my project like save,find,modify,clear and exit. Here my problem is i have to validate in javascript like... TO ADD MORE DETAILS" if yes means go to dropdownlist and if no means go to save
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list without using any button in a table format and one more addtional question
How to add value from sql server in dropdownlist
in dropdownlist
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list without using any button in a table format and one more addtional question
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list without using any button in a table format and one more addtional question
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list without using any button in a table format and one more addtional question
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  //Customer Name: <select name="name"> <% try{ Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  Customer Name:<select name="name"> <% try{ Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc
how to get the values to dropdownlist from oracle database
how to get the values to dropdownlist from oracle database   </script> </head> <body> <select name='countryname' onchange="showState(this.value)"> <option value
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  Can anybody tell me what is the problem in this code as i am not able to fetch the data from the database and set it into dropdown list in jsp please help <br/>
Values from servlet into dropdownlist in jsp page using ajax
Values from servlet into dropdownlist in jsp page using ajax  1) jsp...; <script type="text/javascript"></script> <title>Country</title> <script type="text/javascript"> var htmlres; function
By dropdownlist retrive data from database and show in textbox in jsp.
By dropdownlist retrive data from database and show in textbox in jsp.  Hello Sir, I am doing project in jsp.I have to retrive data from database, when I select value from dropdownlist, and that data I want to show in textbox
dynamic retrival of data from mysql database to dropdownlist in jsp
dynamic retrival of data from mysql database to dropdownlist in jsp  ... database to the dropdownlist in jsp. Example: 1st i want to display the list...="text/javascript"> function showEmp(name){ if(document.getElementById
JavaScript types
JavaScript types  What are JavaScript types
javascript doubt
javascript doubt  How to retrieving the values from Database by using javascript
JavaScript and ECMAScript
JavaScript and ECMAScript  What?s relationship between JavaScript and ECMAScript
JavaScript - JavaScript Tutorial
JavaScript Tutorials is one of the best Quick reference to the JavaScript. In this JavaScript reference you will find most of the things about java script. JavaScript tutorial is classified into sections with examples. This tutorial
JavaScript - JavaScript Tutorial
JavaScript Tutorials is one of the best Quick reference to the JavaScript. In this JavaScript reference you will find most of the things about java script. JavaScript tutorial is classified into sections with examples. This tutorial
Prototypes for JavaScript
Prototypes for JavaScript  What's Prototypes for JavaScript
Prototypes for JavaScript
Prototypes for JavaScript  What's Prototypes for JavaScript
javascript and database
javascript and database  i want to connect javascript pages with msaccess (as a database)how can i do so

Ads