-
<html xmlns="http://www.w3.org/1999/xhtml"><head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<title>Untitled Document</title>
-
<script type="text/javascript">
-
-
function ikel(){
-
-
var sel = document.ikki.sel.value;
-
-
var les = document.getElementById("les");
-
-
-
if(sel=="ikki"){
-
les.innerHTML = "ikki selected";
-
-
}
-
else if(sel=="zick"){
-
les.innerHTML = "zick selected";
-
}
-
else if(sel=="ikel"){
-
les.innerHTML = "ikel selected";
-
}
-
}
-
</script>
-
</head>
-
-
<body bgcolor="#999999">
-
<center>
-
<form name="ikki" >
-
-
<table>
-
<tr>
-
<td>
-
<select onchange="ikel()" name="sel">
-
<option onchange="ikel()" name="sele">ikki</option>
-
<option onchange="ikel()" name="sele">zick</option>
-
<option onchange="ikel()" name="sele">ikel</option>
-
</select>
-
</td>
-
</tr>
-
</table>
-
result=<font color="#990000"><span class="result" id="les" spry:content="ikel()"></span></font><br>
-
<input type="text" name="put" id="les" onchange="ikel()">
-
<br>
-
-
-
-
</form>
-
<!--hello I need Help... how can I output the value of the select tag to the text field using javascript... please help me... thank you .... and Godbless-->
-
</center>
-
<center>
-
-
</center>
-
</body>
-
</html>
Are you trying this: -
<html>
-
-
<head>
-
<script language='javascript' type='text/javascript'>
-
function changer()
-
{
-
document.getElementById('txt_box').value=document.getElementById('sel_box').options[document.getElementById('sel_box').selectedIndex].value;//Value;
-
}
-
</script>
-
</head>
-
-
<body>
-
-
<select id='sel_box' onchange='javascript:changer();'>
-
<option>orange</option>
-
<option>white</option>
-
<option>red</option>
-
<option>green</option>
-
</select>
-
-
<input id='txt_box' type='text' value='message' size='50'/>
-
-
</body>
-
</html>
-
18 5505
how can I output the value of the select tag to the text field using javascript
by using the right properties. an <input> element is always empty, hence it does not have an .innerHTML property!
additionally, <option> elements do not have a name (what for?) and they also do not change (hence the onchange property is pointless).
i forgot to delete the option name... can you give some example code to output the value from select tag to textfield? please... and thank you very much for your response :)
Are you trying this: -
<html>
-
-
<head>
-
<script language='javascript' type='text/javascript'>
-
function changer()
-
{
-
document.getElementById('txt_box').value=document.getElementById('sel_box').options[document.getElementById('sel_box').selectedIndex].value;//Value;
-
}
-
</script>
-
</head>
-
-
<body>
-
-
<select id='sel_box' onchange='javascript:changer();'>
-
<option>orange</option>
-
<option>white</option>
-
<option>red</option>
-
<option>green</option>
-
</select>
-
-
<input id='txt_box' type='text' value='message' size='50'/>
-
-
</body>
-
</html>
-
make that document.getElementById('txt_box').value = document.getElementById('sel_box').value; , the value attribute for the <option>s has not been set.
thank you ariful alam, but i need to output the value of select tag to textbox using if/else if statement... - if(sel=="ikki"){
-
les.innerHTML = "ikki selected";
-
-
}
-
else if(sel=="zick"){
-
les.innerHTML = "zick selected";
-
}
-
else if(sel=="ikel"){
-
les.innerHTML = "ikel selected";
-
}
for example... I selected "zick" in select tag. the value that must be output to textfield is "zick selected".... you gave to me the value of select tag and you output it to textfield... and you dont used if/else if statements to your javascript function... thank you :)
I've got it !.... thank you for some sample codes that you made... -
-
<html>
-
-
<head>
-
<script language='javascript' type='text/javascript'>
-
-
function ikel()
-
{
-
-
var sel = document.ikki.sel.value;
-
-
if(sel=="Zick")
-
{
-
document.getElementById('txt_box').value=document.getElementById('select_tag').options[document.getElementById('select_tag').selectedIndex].value="Zick is Emo!";
-
}
-
if(sel=="Ikel")
-
{
-
document.getElementById('txt_box').value=document.getElementById('select_tag').options[document.getElementById('select_tag').selectedIndex].value="Ikel is Handsome!";
-
}
-
if(sel=="Ikki")
-
{
-
document.getElementById('txt_box').value=document.getElementById('select_tag').options[document.getElementById('select_tag').selectedIndex].value="Ikki is naughty!";
-
}
-
}
-
</script>
-
</head>
-
-
<body>
-
<form name="ikki">
-
-
<select id="select_tag" onchange="ikel()" name="sel">
-
<option>Zick</option>
-
<option>Ikel</option>
-
<option>Ikki</option>
-
</select>
-
-
<input id='txt_box' type='text' value='select to select tag' onchange="ikel()"/>
-
</form>
-
</body>
-
</html>
-
-
thats my code to out put the value of select tag to textfield using if statement... hehe... thank you for some response... salamat..
@Exequiel
What you did, is wrong. You did the following to show a spacific message in text box for every selection from select box: -
document.getElementById('txt_box').value=document.getElementById('select_tag').options[document.getElementById('select_tag').selectedIndex].value="Message is here";
-
but by doing this you can change text box message one time for every selection. means if you select "ikel" first time it will show the message for "ikel". but selecting again "ikel" after selecting any other name, it will not show the message for "ikel".
because you used the following setting:
text box value = selected value = message
this change text in text box as well as change the value of select tag's value of selected text.
so, you need to do the following to show the specific message for specific selected text every time: -
document.getElementById('txt_box').value="Message is here.";
-
Hope you understand. :)
Thank you for your codes Mr. ariful alam... :)
You are most welcome, Exequiel. :)
- <html>
-
<head>
-
<title>E Vibar</title>
-
<script type="text/javascript">
-
function ikel()
-
{
-
var sel = document.ikki.sel.value;
-
if(sel=="T-shirt")
-
{
-
document.ikki.brand.options.length=0;
-
document.ikki.tekz.value=null;
-
var shirt = ["bench","cotton republic"];
-
var shirt_len=shirt.length;
-
for(var ii=0; ii<shirt_len; ii++)
-
{
-
document.ikki.brand.options[ii]=new Option(shirt[ii], ii);
-
if(shirt[ii]=="bench")
-
{
-
document.ikki.tekz.value="Bench is Selected";
-
}
-
else if(shirt[ii]=="cotton republic")
-
{
-
document.ikki.tekz.value="Cotton Republic is selected";
-
}
-
}
-
}//end of if statement T-shirt
-
-
if(sel=="CARS")
-
{
-
var car = ["Toyota","Honda", "Forbes", "Mitsubishi", "Kia", "Nissan"];
-
var car_len=car.length;
-
var cc=0;
-
document.ikki.brand.options.length=0;
-
document.ikki.tekz.value=null;
-
for(var cc=0; cc<car_len; cc++)
-
{
-
document.ikki.brand.options[cc]=new Option(car[cc], cc);
-
}
-
}//end of if statement Cars
-
-
if(sel=="Porn Site")
-
{
-
var por = ["Mofos.com","Naughty America.com", "Erotica.com"];
-
var por_len=por.length;
-
var xx=0;
-
document.ikki.brand.options.length=0;
-
document.ikki.tekz.value=null;
-
for(var xx=0; xx<por_len; xx++)
-
{
-
document.ikki.brand.options[xx]=new Option(por[xx], xx);
-
}
-
}//end of if statement Pron Sites
-
}//end of function ikel
-
window.onload=ikel;
-
</script>
-
</head>
-
<body>
-
<form name="ikki">
-
Menu <select name="sel" onclick="ikel()" id="selected" >
-
<option >T-shirt</option>
-
<option >CARS</option>
-
<option >Porn Site</option>
-
</select>
-
Brand <select name="brand" ><!--option output--></select>
-
<input type="text" name="tekz" id="tikz" onchange="ikel()"/>
-
</form>
-
</body>
-
</html>
I have a problem Inside the if/else if statement... Every time I choose in the Menu select tag the T-shirt, in the Brand Select tag The first is the bench, but the output in the text field is the "Cotton Republic is selected", and when I'm going to select the bench it doesn't change the value in the text field... What syntax I must use just to output the right value? ? . . . :) Thank you :)
You are doing wrong. you are trying to do two work using one fucntion named ikel(). you have to create two individual function like data_binder() and message_shower().
the data_binder() function binds new data to "brand" select tag by every selection of "sel" select tag.
and the message_shower() function add value to "tikz" textbox by every selection of "brand" select tag.
moreover, there is another fault in your tag.
you have to use data_binder() function in "onclick" or "onchange" event of "sel" select tag.
and message_shower() function in "onclick" or "onchange" event of "brand" select tag.
- <html>
-
<head>
-
<title> E Vibar </title>
-
<style type="text/css">
-
#select
-
{
-
height:28px; width: 150px; margin-right: 0px; color:#153846; font-size: 13px; font-variant: normal; line-height: normal; background: #FFF; margin:5px; text-shadow:1px 1px 1px #FFF;border-radius: 5em 2em; border-radius-topright: 3em; border-radius-topleft: 1em; 9px; border: 1px groove #CCC; box-shadow: 2px 2px 15px #2F2727;
-
}
-
-
#text_field
-
{
-
height: 27px; width: 170px; padding: 5px 5px 5px 5px; margin-right: 0px; color:#153846; font-size: 13px; font-variant: normal; line-height: normal; background: #FFF; border: 1px groove #CCC; margin:5px; box-shadow: 2px 2px 15px #2F2727; text-shadow:1px 1px 1px #FFF; border-radius: 5px;
-
}
-
-
#content
-
{
-
width:900px; height:200px; text-decoration:none; margin-right:-7px; font-family:"Arial Black", Gadget, sans-serif; color:#FFF; border-bottom:none; border: 1px groove ; text-shadow:2px 2px 8px #CCC; background: -webkit-gradient(radial, center center, 0, center center, 460, from(#1a82f7), to(#2F2727)); background: -webkit-radial-gradient(circle, #FF8000, #FC0); background: -moz-radial-gradient(circle, #EC7600, #FFA851); background: -ms-radial-gradient(circle, #009BE6, #FC0); box-shadow: 2px 2px 15px #999; text-align:center; border-radius: 1em 9em; border-radius-topright: 7em; border-radius-topleft: 1em;
-
}
-
</style>
-
<script type="text/javascript">
-
var ii;
-
var shirt = ["bench","cotton republic"];//option in brand for shirt
-
var car = ["Toyota","Honda", "Forbes", "Mitsubishi", "Kia", "Nissan"];
-
var por = ["Mofos.com","Naughty America.com", "Erotica.com"];
-
-
function ikel()
-
{ var select_tag = document.ikki.select_tag.value;
-
document.ikki.brand.options.length=0;
-
document.ikki.tekz.value=null;
-
-
if(select_tag=="T-shirt")
-
{
-
for( ii=0; ii<shirt.length; ii++)
-
{ document.ikki.brand.options[ii]=new Option(shirt[ii], ii);
-
-
function callme(){
-
var message=0;
-
message=arguments.length;
-
for(var zx=0; zx<=ii; zx++)
-
{
-
if(zx==ii)
-
{
-
document.ikki.tekz.value="Bench is selected";
-
}
-
else if(zx==ii){
-
document.ikki.tekz.value="Cotton republic is selected";
-
}
-
}//end of for loop for arguments
-
}//end of function call me
-
callme("Bench is selected", "Cotton republic is selected");//call me function, to be output to textfield
-
}//end of loop
-
}//end of if statement T-shirt
-
-
if(select_tag=="CARS")
-
{
-
for(var ii=0; ii<car.length; ii++)
-
{
-
document.ikki.brand.options[ii]=new Option(car[ii], ii);
-
}//end of for loop
-
}//end of if statement Cars
-
-
if(select_tag=="Porn Site")
-
{
-
for(ii=0; ii<por.length; ii++)
-
{
-
document.ikki.brand.options[ii]=new Option(por[ii], ii);
-
}
-
}//end of if statement Pron Sites
-
}//end of function ikel
-
window.onload=ikel;
-
</script>
-
</head>
-
<body>
-
<center>
-
<br><br>
-
<div id="content">
-
<br><br>
-
<form name="ikki">
-
Menu <select name="select_tag" onclick="ikel()" id="select">
-
<option >T-shirt</option>
-
<option >CARS</option>
-
<option >Porn Site</option>
-
</select>
-
Brand <select name="brand" spry:choose="ikel()" id="select"><!--option output--></select>
-
<input type="text" name="tekz" id="text_field" disabled onclick="callme()"/>
-
</form>
-
</div>
-
</center>
-
</body>
-
</html>
I created function inside ikel(), its called callme()... I need to output the values of call me individualy to the textfield... for example... if I selected bench in the select tag the output must be Bench is selected . . . I dont know how to determine if how to select bench to output the Bench is selected inside the for loop and if/else if statement... its so confusing . . . :) thanks again for your response... :)
In your code you created a function named callme() inside the ikel() function that takes no parameter. but when you called the callme() function inside the ikel() function that takes parameter. whenever a few funcions with the same name with different parameter, those do not treat equal. because those are different. so, answer will not happen or error throwed.
moreover, in your page, you require text box to show a message whenever you select a option from select_tag or from brand. so, you need a common function that can used in those two select tag. for this, it is better to use a single function in your code. i changed a little bit in your code. check the following. -
<html>
-
<head>
-
<title> E Vibar </title>
-
-
<style type="text/css">
-
#select{
-
height:28px; width: 150px; margin-right: 0px; color:#153846; font-size: 13px; font-variant: normal; line-height: normal; background: #FFF; margin:5px; text-shadow:1px 1px 1px #FFF;border-radius: 5em 2em; border-radius-topright: 3em; border-radius-topleft: 1em; 9px; border: 1px groove #CCC; box-shadow: 2px 2px 15px #2F2727;
-
}
-
-
#text_field{
-
height: 27px; width: 170px; padding: 5px 5px 5px 5px; margin-right: 0px; color:#153846; font-size: 13px; font-variant: normal; line-height: normal; background: #FFF; border: 1px groove #CCC; margin:5px; box-shadow: 2px 2px 15px #2F2727; text-shadow:1px 1px 1px #FFF; border-radius: 5px;
-
}
-
-
#content{
-
width:900px; height:200px; text-decoration:none; margin-right:-7px; font-family:"Arial Black", Gadget, sans-serif; color:#FFF; border-bottom:none; border: 1px groove ; text-shadow:2px 2px 8px #CCC; background: -webkit-gradient(radial, center center, 0, center center, 460, from(#1a82f7), to(#2F2727)); background: -webkit-radial-gradient(circle, #FF8000, #FC0); background: -moz-radial-gradient(circle, #EC7600, #FFA851); background: -ms-radial-gradient(circle, #009BE6, #FC0); box-shadow: 2px 2px 15px #999; text-align:center; border-radius: 1em 9em; border-radius-topright: 7em; border-radius-topleft: 1em;
-
}
-
</style>
-
-
<script type="text/javascript">
-
var ii;
-
var shirt = ["bench","cotton republic"];//option in brand for shirt
-
var car = ["Toyota","Honda", "Forbes", "Mitsubishi", "Kia", "Nissan"];
-
var por = ["Mofos.com","Naughty America.com", "Erotica.com"];
-
-
function ikel() {
-
var select_tag = document.ikki.select_tag.value;
-
document.ikki.brand.options.length=0;
-
document.ikki.tekz.value=null;
-
-
if(select_tag=="T-shirt") {
-
for( ii=0; ii<shirt.length; ii++) {
-
document.ikki.brand.options[ii]=new Option(shirt[ii]);
-
}//end of for loop
-
}//end of if statement T-shirt
-
-
if(select_tag=="CARS") {
-
for(var ii=0; ii<car.length; ii++) {
-
document.ikki.brand.options[ii]=new Option(car[ii]);
-
}//end of for loop
-
}//end of if statement Cars
-
-
if(select_tag=="Porn Site") {
-
for(ii=0; ii<por.length; ii++) {
-
document.ikki.brand.options[ii]=new Option(por[ii]);
-
}
-
}//end of if statement Pron Sites
-
-
text_changer();
-
-
}//end of function ikel
-
-
function text_changer() {
-
document.ikki.tekz.value=document.ikki.brand.value + " is selected";
-
}
-
window.onload=ikel;
-
</script>
-
-
</head>
-
-
<body>
-
<center>
-
<br><br>
-
<div id="content">
-
<br><br>
-
<form name="ikki">
-
Menu <select name="select_tag" onclick="ikel()" id="select">
-
<option >T-shirt</option>
-
<option >CARS</option>
-
<option >Porn Site</option>
-
</select>
-
Brand <select name="brand" id="select" onchange="text_changer();"><!--option output--></select>
-
<input type="text" name="tekz" id="text_field" disabled>
-
</form>
-
</div>
-
</center>
-
</body>
-
</html>
ah... I see... hehe... thank you very much for your codes.... I know that this problem that I've posted here is so easy for you and for others,,, hehe... I'm just a Beginner in java script,,, thank you very much... :) you helped me so much ariful alam... :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dom Nicholas |
last post by:
Hi,
I have a table (inside a form) that is dynamically created ie the user
can add / remove rows dynamically. Each table row has 4 columns :
a selection pull down list
a text field for...
|
by: Stumped and Confused |
last post by:
Hello,
I really, really, need some help here - I've spent hours trying to find a
solution.
In a nutshell, I'm trying to have a user input a value in form's
textfield. The value should then be...
|
by: Santosh |
last post by:
Hi,
I have a requirement in which, I need to capture a loan amount and the
amount of down payment for that loan. According to the requirement,
the user is going to enter enter the loan amount and...
|
by: Peter S |
last post by:
Hi:
I am trying to read a SQL Server text field (Access memo field) using
connection.OpenRecordSet("qry with text field")
rather than
database.OpenRecordSet("qry with text field")
|
by: Abhishek |
last post by:
Hi this is my another validator in javascript to validate the Phone
Number :-)
<script language='javascript'>
function funcCheckPhoneNumber(ctrtxtMobile,e){
if(window.event){
var strkeyIE =...
|
by: baburmm |
last post by:
hello friends i want to get the footer row textbox value of the gridview using javascript for validating it.
how can i get it is there any coding
pls help me
Thanks in advance,
Regards.
Babu.K
|
by: baburmm |
last post by:
hello friends i want to get the footer row textbox value of the gridview using javascript for validating it.
how can i get it is there any coding
pls help me
Thanks in advance,
Regards.
Babu.K
|
by: kirankumarn |
last post by:
I want to read xml which is stored in hidden field using javascript
|
by: dev saini |
last post by:
how to remove number one by one in the calculator text box using JavaScript. its urgent
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |