Home Answers Viewqa JSP-Servlet select option with text facility

 
 


kripa
select option with text facility
5 Answer(s)      4 years and 2 months ago
Posted in : JSP-Servlet

View Answers

March 23, 2009 at 12:05 AM


Hi friend,

Code to help in solving the problem :

<HTML>
<HEAD>
<TITLE>Editable Dropdown / Listbox / Combobox - HTML, JavaScript</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function keyDown(getdropdown, e)
{
checkFn(getdropdown);
var vEventKeyCode = keyCode(e);
// Press left/right arrow keys
if(vEventKeyCode == 37)
{
fnLeftToRight(getdropdown);
}
if(vEventKeyCode == 39)
{
fnRightToLeft(getdropdown);
}

// Delete key pressed
if(vEventKeyCode == 46)
{
fnDelete(getdropdown);
}

// backspace key pressed
if(vEventKeyCode == 8 || vEventKeyCode==127)
{
if(e.which) //Netscape
{
//e.which = ''; //this property has only a getter.
}
else //Internet Explorer
{
//To prevent backspace from activating the -Back- button of the browser
e.keyCode = '';
if(window.event.keyCode)
{
window.event.keyCode = '';
}
}
return true;
}

// Tab key pressed, use code below to reorient to Left-To-Right flow, if needed
//if(vEventKeyCode == 9)
//{
// fnLeftToRight(getdropdown);
//}
}

function fnLeftToRight(getdropdown)
{
getdropdown.style.direction = "ltr";
}

function fnRightToLeft(getdropdown)
{
getdropdown.style.direction = "rtl";
}

function fnDelete(getdropdown)
{
if(getdropdown.options.length != 0)
// if dropdown is not empty
{
if (getdropdown.options.selectedIndex == vEditableOptionIndex_A)
// if option the Editable field
{
getdropdown.options[getdropdown.options.selectedIndex].text = '';
getdropdown.options[getdropdown.options.selectedIndex].value = '';
}
}
}

March 23, 2009 at 12:06 AM


function keyCode(e)
{
if(e.which)
{
keycode=e.which; //Netscape
}
else
{
keycode=e.keyCode; //Internet Explorer
}

//alert("keyCode"+ keycode);
return keycode;
}

function charKeyFn(e)
{
keycode = keyCode(e);
if((keycode==8)||(keycode==127))
{
character="backspace"
}
else if((keycode==46))
{
character="delete"
}
else
{
character=String.fromCharCode(keycode);
}
//alert("FindKey"+ character);
return character;
}

function checkFn(getdropdown)
{
if(vEditableOptionIndex_A>(getdropdown.options.length-1))
{
alert("PROGRAMMING ERROR: The value of variable vEditableOptionIndex_... cannot be greater than (length of dropdown - 1)");
return false;
}
}
</SCRIPT>

March 23, 2009 at 12:07 AM



<SCRIPT LANGUAGE="JavaScript">



var vEditableOptionIndex_A = 0;



var vEditableOptionText_A = "--?--";



var vPreviousSelectIndex_A = 0;


var vSelectIndex_A = 0;


var vSelectChange_A = 'MANUAL_CLICK';


function changeFn(getdropdown)
{
checkFn(getdropdown);

vPreviousSelectIndex_A = vSelectIndex_A;

vSelectIndex_A = getdropdown.options.selectedIndex;


if ((vPreviousSelectIndex_A == (vEditableOptionIndex_A)) && (vSelectIndex_A != (vEditableOptionIndex_A))&&(vSelectChange_A != 'MANUAL_CLICK'))

{
getdropdown[(vEditableOptionIndex_A)].selected=true;
vPreviousSelectIndex_A = vSelectIndex_A;
vSelectIndex_A = getdropdown.options.selectedIndex;
vSelectChange_A = 'MANUAL_CLICK';

}
}

function pressFn(getdropdown, e)
{
checkFn(getdropdown);

keycode = keyCode(e);
keychar = charKeyFn(e);


if ((keycode>47 && keycode<59)||(keycode>62 && keycode<127) ||(keycode==32))
{
var vAllowableCharacter = "yes";
}
else
{
var vAllowableCharacter = "no";
}


if(getdropdown.options.length != 0)

if (getdropdown.options.selectedIndex == (vEditableOptionIndex_A))

{

var vEditString = getdropdown[vEditableOptionIndex_A].value;


if((vAllowableCharacter == "yes")||(keychar=="backspace"))
{
if (vEditString == vEditableOptionText_A)
vEditString = "";
}
if (keychar=="backspace")
{
vEditString = vEditString.substring(0,vEditString.length-1);


vSelectChange_A = 'MANUAL_CLICK';

}


if (vAllowableCharacter == "yes")

{
vEditString+=String.fromCharCode(keycode);


var i=0;
var vEnteredChar = String.fromCharCode(keycode);
var vUpperCaseEnteredChar = vEnteredChar;
var vLowerCaseEnteredChar = vEnteredChar;


if(((keycode)>=97)&&((keycode)<=122))

vUpperCaseEnteredChar = String.fromCharCode(keycode - 32);



if(((keycode)>=65)&&((keycode)<=90))

vLowerCaseEnteredChar = String.fromCharCode(keycode + 32);

if(e.which)
{

for (i=0;i<=(getdropdown.options.length-1);i++)
{
if(i!=vEditableOptionIndex_A)
{
var vReadOnlyString = getdropdown[i].value;
var vFirstChar = vReadOnlyString.substring(0,1);
if((vFirstChar == vUpperCaseEnteredChar)||(vFirstChar == vLowerCaseEnteredChar))
{
vSelectChange_A = 'AUTO_SYSTEM';

break;
}
else
{
vSelectChange_A = 'MANUAL_CLICK';

}
}
}
}
}

// Set the new edited string into the Editable option
getdropdown.options[vEditableOptionIndex_A].text = vEditString;
getdropdown.options[vEditableOptionIndex_A].value = vEditString;

return false;
}
return true;
}

March 23, 2009 at 12:07 AM


function keyUpFn(getdropdown, e)
{
checkFn(getdropdown);

if(e.which) // Netscape
{
if(vSelectChange_A == 'AUTO_SYSTEM')
{

getdropdown[(vEditableOptionIndex_A)].selected=true;
}

var vEventKeyCode = keyCode(e);
// if [ <- ] or [ -> ] arrow keys are pressed, select the editable option
if((vEventKeyCode == 37)||(vEventKeyCode == 39))
{
getdropdown[vEditableOptionIndex_A].selected=true;
}
}
}



</SCRIPT>

March 23, 2009 at 12:08 AM


</HEAD>
<BODY>
<FORM name="selectFrm" method="post">
<center>
<br>
<SELECT name="user" id="user" style="" onKeyDown="keyDown(this, event);" onKeyUp="keyUpFn(this, event); return false;" onKeyPress = "return pressFn(this, event);" onChange="changeFn(this, event);">
<OPTION value=""></OPTION>
<option>option1</option>
<option>option2</option>
<option>option3</option>
<option>option4</option>
<option>option5</option>
</SELECT>
<br>
</center>
</FORM>
</BODY>
</HTML>

Thanks









Related Pages:
select option with text facility - JSP-Servlet
select option with text facility  Hello. My doubt is regarding how to provide facility to add text in a drop down box ie(select tag in html )in a jsp... the select in html and if the user wants also to directly type the option instead
select option value
select option value  if i select a value of any drop down...("Select * from country"); while(rs.next()){ %> <option value... id='state'> <select name='state' > <option value='-1
select option value
select option value  if i select a value of any drop down then that value should be used in a select query of the next dropdown in jsp on same page... buffer="<select name='state' ><option value='-1'>Select</option>
jsp drop down-- select Option
;nbsp;</td> <select name="sel"><option value=""><---Select..."); String buffer="<select name='state'><option value='-1'>Select<...jsp drop down-- select Option  how to get drop down populated
validate select option jquery
validate select option jquery  How to Validate select option in JQuery
select option - JDBC
select option  how to dynamically generate the select option values from database
jQuery change event with multiple select option
;; $("select option:selected").each(function () { str += $(this).text...jQuery change event with multiple select option In this tutorial , we...; it also display the selected option. In the below example a multiple select list
Javascript get Date And Selected Option Text
Javascript get Date And Selected Option Text In this tutorial we will learn... to get the selected option text and displayed in Javascript. This tutorial explains you that how to display the date and the selected option text in Javascript
how to create text file from jsp and provide downlode option
of this page in text file and also downlode option of this text field thanks...how to create text file from jsp and provide downlode option  HI... in java/j2ee tech. my question is who do i make a jsp output in the form of text
Select from select list + display
Select from select list + display  i have a select list containing... select EmpCode from the select list, the corresponding EmpName and DeptName should be displayed automatically in empty text fields. I am using struts 1.2
nested select tag
("count"); String buffer="<select name='state'><option value='-1'>...nested select tag  My requirement is as follows suppose combobox to select country whenever i select a country it will show corresponding states
Multiple select box
Multiple select box  Hi, I need help in code for multiple select box. The multiple select box should be populated with the db values.The selection done in the multiple select box is to be moved to the text area provided a add
Select DropDown Default
Select DropDown Default  Hi there, i have a program in JSP where i..., i.e if the user select PAGE 1 in the dropdown menu, it will display all.... the problem is if the user select "View ALL Pages" it will dislay nothing. what
dynamic select box
dynamic select box  thank u my dear friend.but i have a code like...;/label></td> <td><input type="text" name="lastname" value...;First Name</label></td> <td><input type="text" name
How to add another option to the select tag using struts2 tag - Struts
How to add another option to the select tag using struts2 tag  Hi, How to add another option to select tag using tag. My scenario is : If the logged in user is admin then drop down should contain the normal list
select box and text box validations
select box and text box validations  hi, any one please tell me how to set validations for select box and text boxes using bean classes? thank you   Please visit the following link: http://www.roseindia.net/jsp/user
Add values of drop down menu( select option) to mysql table
Add values of drop down menu( select option) to mysql table   Here...['valveId'].'<td>'; echo '<select name="onoff">'; echo '<option value="ON">ON'; echo '</option>'; echo '<option
For every option selected from a dropdown a new textbox opens
For every option selected from a dropdown a new textbox opens  I have a dropdown with four options, each time I select an option a new text box...;select name="sel" onchange="generateTextbox();"> <option value="C/C++">
Dojo Filtering Select
Dojo Filtering Select        ... select.  FilteringSelect: The FilteringSelect is same as html select tag... in the combo box. It allows only the selection facility. But filteringselect allows
How to show autocomplete textbox values on combo box option selection using database?
How to show autocomplete textbox values on combo box option selection using database?  When I select option(i.e First Year) then it will show list of student names in auto-complete text box
Option Box Value - Java Beginners
Option Box Value  Hi Friends, I have one option box which is division, division have dynamically data,if user select any division then his option box is populated (work schedule,Peronal Area,personal sub area,business
Column select
Column select   How i fetch Experience wise resume?   ... or no. Then using the query select * from resumes where experience='yes', fetch all the data...("jdbc:mysql://localhost:3306/test", "root", "root"); String query = "select * from
Option onclick am not getting the value ..
Option onclick am not getting the value ..    function get_val( tot_val ) { document.getElementById('TextBox1').value = tot_val; } <..." rows="5" cols="20">   Here is a simple code that insert some text
Select Tag&lt;html:select&gt;:
browser displays the following page. Don't select the option... selecting option... Now select any option...html:select Tag : Creates a HTML <select> element, associated
JavaScript remove method
. <select id="myselect"> <option value="... from the select tag option list. Here is the full example code... this example we don't have select any item therefore it removes first option
Use of Text Field
to allow the user to select one option out of a number of choices. Example... option out of many given choices. Example Text Area: A text area is an area... Use of Text Field, Text box, Text Area, Checkbox,Dropdownlist and Radio
jQuery image replacement by click or select
by button click or by selecting an option of select drop down box without refreshing... () { $("select option:selected").each(function () { $("#img").attr...;target"> <option value="" selected="selected">Select
Table's row elimination based on option choosen
Table's row elimination based on option choosen  I have a drop down with yes and no option.if i select yes in a table 2 new rows are shown and if i select no another question in row appears but the space occupied by the question
Multiple select dropdown with Ajax
Multiple select dropdown with Ajax This tutorial explains how to create...;%@ page language="java" contentType="text/html; charset...="text/html; charset=ISO-8859-1"> <title>Multiple
JavaScript add method
. Here in this example we have added an option to the select tag by using the add... : it is the option value which is to be added into the select tag's option list... value to be added and it is also required while adding some option to the select
Input type select
the size of the SELECT element specified is 2. Why is it so? Select a Country: <select name="country" size="2"> <option name="Australia" value="Australia" selected="selected">Australia</option> <option name
How to make a text effect.
text effect in the Photoshop, so you can use any option for that. New File: First take a new file, adjust the file size as you want. Write Text: Select...;Contract" option so go to Select menu > Modify > Contract, set
Jsp Option Value
;option value="">--select--</option> <option value...;/td> <select name="sel"><option value=""><---Select---><... Jsp Option Value   
a jsp code for creating a text file
of them.If the user select first option that is 1.creating a new file.Then a new jsp page...a jsp code for creating a text file  Hello,i need jsp code for creating a new text file for each user, when they login in to the website for creating
gradient text, text effect, text
to take a new file with black background as here. Write Text: Select Horizontal... How to make a gradient text       We can make many different type of text by the help
Select Color
Select Color      ... firstly we need to make one html page. Inside the page we will have one select option in which we will have our colors. We will also have a submit, clicking
How to make an animated text border, make an animated text border, animated text border
of the text. Expand: Now go to Select menu > Modify >Apply Expand... How to make an animated text border       Learn an animation by this example, it is a text
Block edit menu option - JSP-Servlet
Block edit menu option  I am doing a jsp project. I have to control number of characters in a text area upto a limit. How can i block pasting through edit menu and pasting through short cut key [ctrl+v
How to make an image full text.
option to make an image full text so follow now. Open a file: First open an image file in which image you want to insert in the text. Text: Select... into the text as here. Complete Writing Text: After completed writing text select
Dynamic select box - Ajax
Dynamic select box  Hi, I Have almost completed the task... select boxes in my page.. One is "Select a Country" and other one is "Select... in the other select box automatically.. The city details must be extracted from
HTML5 option tag, Example of &lt;option&gt;tag.
attributes> Text </option > Example of <option> in HTML5: Code...HTML5 option tag, Example of <option> tag. Here, you will see the use... option for drop-down list or selection list. Every thing presents in option tag
Use of Select Box to show the data from database
;. In this page, item selected in the select box is shown in the text box correspondingly... in the select box and correspondingly reflect it to the text box. We are using a function... select any other item from select box then it will reflect to the text box as well
JavaScript getElementById select
JavaScript getElementById select... to perform any operation with the selected value as a option. We will be describing you here to use getElementById with select by using a very simple example
PHP Form Part-6 - How to Deals with Text Boxs
button does not give the choice to the users to select multiple option...Topic : HTML FORM - How to Deal with Text Boxs in PHP Part - 6 In the previous part of HTML FORM tutorial, we learned how to deal with text box.  
Text Editor Extensions
/standard output. When you select this option, Eclipse displays a dialog asking... select the Direct filter output to console instead of replacing selection option... Text Editor Extensions     
populating text box using jsp code
"); %> <select id="book" onchange="change();"> <option value="0">--Please Select--</option> <% while(rs.next()){ %> <option value...;% } } %> </select> <select id="info" onchange="extract(this)"> <option
jQuery 'select' form event
input box. In this Example, two input text box are given , when we select...; Click and drag the mouse to select text in the input box. </p>...; OUTPUT When we select some text inside inputs : Download Source Code Click
JSF Select one menu - Framework
JSF Select one menu  Hi, I am new in Jsf, I use one this is based on some table in MySQL, Data is coming in this select box, but I want also show â??selectâ?? option in first position. I also use above This is giving
JavaScript validate select tag
JavaScript validate select tag In this tutorial, you will learn how to validate html select tag. Here, we have used two select tags to select numbers in order to calculate addition of two numbers. If the user does not select any
text pad settings with java - Java Beginners
text pad settings with java  hello sir.I want to use textpad editor... but "java command" option is not displaying. Can you please tell me how can i set up.... 3) After installing open Textpad and select Configure, then Preferences

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.