Filling Input=text with Select Options

I'm trying to fill an input form with different select box, for example:

(The example below does not work at all )

http://jsfiddle.net/K35er/1/ (The example above does not work at all )

but the goal is to get all the values in the input but in this format :

1/2 R3

where 1 is #select , 2 is #select2 & R3 is #select3

is this possible??

thanks

Answers


You need to use .val() to get the value of the selected option. In you onchange handler you need something like below,

$(".myselect").change(function () {
    $("#hiddenNOT").val($('#select').val() + '/' + $('#select2').val() + ' ' + $('#selec3').val());
});

DEMO: http://jsfiddle.net/K35er/3/


$("select").change(function () {

    $("#hiddenNOT").val(
           $("#select").val()+'/'+
           $("#select2").val()+'R'+
           $("#selec3").val()
         );
});

DEMO: http://jsfiddle.net/K35er/5/

HTML

<select id="select1">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>    
</select>

<select id="select2">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>    
</select>

<select id="select3">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>    
</select>

<input type='text' id='hiddenNOT' value=''/>

JavaScript

$("select").change(function () {
    $("#hiddenNOT").val($('#select1').val() + '/' + $('#select2').val() + ' R' + $('#select3').val());
});

Need Your Help

Putting a delay in ajax script

javascript ajax jquery

anyone have any idea how t put a 10 second delay between posting the photo and tagging? The script makes the tags instantly after the photo is uploaded but I want a delay.

Pointing SVN workspace to different server & repository with different parent directory

svn tortoisesvn migration

I have an svn repository that is slated EOL, and the various projects are being moved through svnrdump dump and svnadmin load to a new repository. For the purposes of discussion, the basic topolog...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.