Click here to Skip to main content
15,902,635 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionJavaScript Validation - DropDownLists Pin
EuphorialXTC15-Jul-12 23:04
EuphorialXTC15-Jul-12 23:04 
AnswerRe: JavaScript Validation - DropDownLists Pin
Sibasisjena16-Jul-12 0:08
professionalSibasisjena16-Jul-12 0:08 
AnswerRe: JavaScript Validation - DropDownLists Pin
jkirkerx19-Jul-12 8:57
professionaljkirkerx19-Jul-12 8:57 
Questionusing createElement, not working in IE8 on XP and Server 2003 Pin
jkirkerx13-Jul-12 16:42
professionaljkirkerx13-Jul-12 16:42 
General[solved] Re: using createElement, not working in IE8 on XP and Server 2003 Pin
jkirkerx15-Jul-12 16:46
professionaljkirkerx15-Jul-12 16:46 
Questionc# Webbrowser javascript submit then blank page Pin
koncuk12-Jul-12 3:36
koncuk12-Jul-12 3:36 
AnswerRe: c# Webbrowser javascript submit then blank page Pin
Sibasisjena12-Jul-12 4:30
professionalSibasisjena12-Jul-12 4:30 
GeneralHow to get the objects of the selected ITem Pin
Vimalsoft(Pty) Ltd11-Jul-12 23:27
professionalVimalsoft(Pty) Ltd11-Jul-12 23:27 
Good day

i am new to knockout ,

I am bringing back the data from a control and i am doing the autocomplete and i show the results in a listbox as depicted below


JavaScript
$(function () {
    $("#txtSearchString").keyup(function () {
        $("#lstSearchOptions").hide('fast');

 
        if ($("#txtSearchString").val().length >= 3)
        {
            var data = {}
            data.searchString = $("#txtSearchString").val();
            $.getJSON("/SearchCars/SearchCars", data, function (result) {
                //Autocomplete binding
                var viewModel =
                 {

                     SearchOptions: ko.observableArray(result), // These are the initial options 
              
                } 
                //item.Model + ' ' + item.Type + ' ' + item.Year
                ko.applyBindings(viewModel,document.getElementById("stSearchOptions"));
                ko.applyBindings(viewModel, document.getElementById("selectedcarid"));
                if (result != null)
                {
                    $("#lstSearchOptions").show('fast');
                }
            });
        }
    });
});


now when the user select something i need to get the selected ID and i also want the Year and this is my HTML


HTML
<select id="lstSearchOptions" data-bind="options: SearchOptions, optionsText: function(item) {
                    return item.Model + ' ' + item.Type + ' ' + item.Year}, optionsValue: 'CarId'"
                 multiple="multiple" size="-1" class="searchOptions">
             </select>



and i have this to assign the value

JavaScript
$(function () {
    $("#lstSearchOptions").change(function () { 
        $("#selectedcarid").val($("#lstSearchOptions option:selected").val());

    });

    $("#lstSearchOptions").blur(function () { 
        $("#lstSearchOptions").hide("fast");
     
 
    });
});


so i can get the ID from here

JavaScript
$("#selectedcarid").val($("#lstSearchOptions option:selected").val());


but have a Problem to getting the year

Thanks
Vuyiswa Maseko,

Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com

QuestionAdding a link to a table built in Javascript Pin
offroaderdan7-Jul-12 1:04
offroaderdan7-Jul-12 1:04 
AnswerRe: Adding a link to a table built in Javascript Pin
enhzflep8-Jul-12 22:17
enhzflep8-Jul-12 22:17 
AnswerRe: Adding a link to a table built in Javascript Pin
BobJanova9-Jul-12 1:52
BobJanova9-Jul-12 1:52 
AnswerRe: Adding a link to a table built in Javascript Pin
Sanjay K. Gupta9-Jul-12 3:44
professionalSanjay K. Gupta9-Jul-12 3:44 
AnswerRe: Adding a link to a table built in Javascript Pin
twseitex10-Jul-12 10:30
twseitex10-Jul-12 10:30 
QuestionProblem to add new field in javascript! Pin
Erika Silva4-Jul-12 23:33
Erika Silva4-Jul-12 23:33 
AnswerRe: Problem to add new field in javascript! Pin
Erika Silva5-Jul-12 0:14
Erika Silva5-Jul-12 0:14 
GeneralRe: Problem to add new field in javascript! Pin
Erika Silva5-Jul-12 5:45
Erika Silva5-Jul-12 5:45 
Questionautomatically break page in html code Pin
fsajjad4-Jul-12 1:41
fsajjad4-Jul-12 1:41 
Questionhow can zoom image in a datalist dynamically adding images Pin
shannya3-Jul-12 23:30
shannya3-Jul-12 23:30 
Questionfind words from group of letters in a statement using regularexpression Pin
siva4552-Jul-12 23:46
siva4552-Jul-12 23:46 
AnswerRe: find words from group of letters in a statement using regularexpression Pin
Niral Soni13-Jul-12 2:26
Niral Soni13-Jul-12 2:26 
GeneralRe: find words from group of letters in a statement using regularexpression Pin
Peter_in_278013-Jul-12 11:36
professionalPeter_in_278013-Jul-12 11:36 
Questionneed help to create a dynamic calendar! Pin
Erika Silva2-Jul-12 23:02
Erika Silva2-Jul-12 23:02 
AnswerRe: need help to create a dynamic calendar! Pin
V.4-Jul-12 3:41
professionalV.4-Jul-12 3:41 
GeneralRe: need help to create a dynamic calendar! Pin
Erika Silva4-Jul-12 3:55
Erika Silva4-Jul-12 3:55 
GeneralRe: need help to create a dynamic calendar! Pin
V.10-Jul-12 19:59
professionalV.10-Jul-12 19:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.