jQWidgets Forums

jQuery UI Widgets Forums Lists DropDownList set value from db

This topic contains 11 replies, has 3 voices, and was last updated by  Staale Eikebraaten 12 years, 5 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
  • set value from db #11809

    detberlin
    Participant

    The following example ….

    I have a customer registration.

    I have a dropdownlist …. selectable zip codes, these are predefined in an array …

    I select now the postal code 10407, this also displayed and entered.

    Now I fill up the remaining data set of customer and store.

    I now want to edit a custom data set, do I read the data from the database.
    In the data field now includes the postal code 10407

    which is now where I have problems.

    the dropdownlist contains my predefined array although none has postcode selected
    in the customer record is now 10407 as postcode
    now I want it to me dropdownlist as value the postal code of the customer
    indicates although nothing was selected dropdownlist in.

    But how?

    I hope you have understood my problem

    thanks in advance

    detberlin

    set value from db #11811

    Peter Stoev
    Keymaster

    Hi detberlin,

    I suggest you to take a look at the API Docs for jqxDropDownLsit. To select an item in DropDownList, use the ‘selectIndex’ or ‘selectItem’ methods. To get an item by value, use the getItemByValue method. Here’s also a sample which shows how to get the selected value in PHP: dropdownlist.htm.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    set value from db #11812

    detberlin
    Participant

    hi Peter,

    you misunderstood me.

    do you speak German?

    my english iss not so good

    set value from db #11813

    detberlin
    Participant

    here a example

    function kdnLaden(){
    var regWerben = true; var regLetter = true;
    $.ajax({type: 'POST', async:false, dataType:'json', url:'phregist.php?regWahlen=2&userReg= WHERE regidx01=' + regUser}).done(
    function(prfdata){
    if (prfdata[0].regtxt00 == 'Herr') $('#regRadio1').jqxRadioButton('check'); else $('#regRadio2').jqxRadioButton('check');
    if (prfdata[0].regchk01 == 0) regWerben = false; $('#regCheck1').jqxCheckBox({checked:regWerben});
    if (prfdata[0].regchk02 == 0) regLetter = false; $('#regCheck2').jqxCheckBox({checked:regLetter});
    $('#regFeld01').val(prfdata[0].regtxt01); $('#regFeld02').val(prfdata[0].regtxt02); $('#regFeld03').val(prfdata[0].regtxt03);
    $('#regFeld04').val(prfdata[0].regtxt04); $('#regFeld05').val(prfdata[0].regtxt05); $('#regFeld06').val(prfdata[0].regtxt06);
    $('#regFeld07').val(prfdata[0].regtxt07); $('#regFeld08').val(prfdata[0].regtxt08); $('#regFeld09').val(prfdata[0].regtxt09);
    $('#regFeld11').val(prfdata[0].regtxt11); $('#regFeld12').val(prfdata[0].regtxt12); $('#regFeld13').val(prfdata[0].regtxt13);
    $('#regFeld14').val(prfdata[0].regtxt14);
    $('#regFeld10').jqxDropDownList(prfdata[0].regtxt10); //this is my attempt
    });
    }
    set value from db #11814

    Peter Stoev
    Keymaster

    Hi detberlin,

    I don’t know what is expected from the line below, but it will not initialize the jqxDropDownList widget and will not set/get the selection.

    $('#regFeld10').jqxDropDownList(prfdata[0].regtxt10);

    I suggest you to take a look at the provided samples and read the following Getting Started help topic: jquery-dropdownlist-getting-started.htm.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    set value from db #11817

    detberlin
    Participant

    you understand me not ever,

    my other attempt

    var regPlzArray = ["10115","10117","10119","10178","10179","10243","10247","10249","10369","10405","10407","10409","10435","10437","10439"];
    $('#regFeld10').jqxDropDownList({source:regPlzArray, selectedIndex:-1, width:68, height:20, dropDownHeight:186, itemHeight:23,
    animationType:'none', searchMode:'none', promptText:kdnPlz, theme:'energyblue'});
    function kdnLaden(){
    var regWerben = true; var regLetter = true;
    $.ajax({type: 'POST', async:false, dataType:'json', url:'phregist.php?regWahlen=2&userReg= WHERE regidx01=' + regUser}).done(
    function(prfdata){
    if (prfdata[0].regtxt00 == 'Herr') $('#regRadio1').jqxRadioButton('check'); else $('#regRadio2').jqxRadioButton('check');
    if (prfdata[0].regchk01 == 0) regWerben = false; $('#regCheck1').jqxCheckBox({checked:regWerben});
    if (prfdata[0].regchk02 == 0) regLetter = false; $('#regCheck2').jqxCheckBox({checked:regLetter});
    $('#regFeld01').val(prfdata[0].regtxt01); $('#regFeld02').val(prfdata[0].regtxt02); $('#regFeld03').val(prfdata[0].regtxt03);
    $('#regFeld04').val(prfdata[0].regtxt04); $('#regFeld05').val(prfdata[0].regtxt05); $('#regFeld06').val(prfdata[0].regtxt06);
    $('#regFeld07').val(prfdata[0].regtxt07); $('#regFeld08').val(prfdata[0].regtxt08); $('#regFeld09').val(prfdata[0].regtxt09);
    $('#regFeld11').val(prfdata[0].regtxt11); $('#regFeld12').val(prfdata[0].regtxt12); $('#regFeld13').val(prfdata[0].regtxt13);
    $('#regFeld14').val(prfdata[0].regtxt14);
    // the next methode
    kdnPlz = prfdata[0].regtxt10;});
    }

    kdnPlz = data from Datafield
    promtText = kdnPlz

    i hope this is correct….

    detberlin

    set value from db #11837

    detberlin
    Participant

    hi Peter,

    i hope you can now to reproduce?

    or have you any idea?

    this is not save for me

    greeting Detberlin

    set value from db #11838

    Peter Stoev
    Keymaster

    Hi Detberlin,

    I don’t understand what you try to achieve with your code. If it is to select an item, use the selectIndex method of jqxDropDownList.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    set value from db #11840

    detberlin
    Participant

    i will not select….
    i will display my single record from db in promtText no selected….

    now understand?

    set value from db #11841

    Peter Stoev
    Keymaster

    promptText in jqxDropDownList is displayed only when the selectedIndex is -1. If you want to get the selected item, use the getSelectedItem method.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    set value from db #11842

    detberlin
    Participant

    however my last example works fine,

    it is not safe enough for me.

    have you a example for me?

    i understand english not so good

    I am practitioner and can read the source code
    and then understand better what you meant

    set value from db #13302

    Staale Eikebraaten
    Participant

    Is this what you are looking for detberlin ? How to preset a selected item ?

    var itmx = $(“#dropdownFagkodegruppe”).jqxDropDownList(‘getItemByValue’, ‘Mat’);
    $(“#dropdownFagkodegruppe”).jqxDropDownList(‘selectItem’, itmx);

    As I dont have the index number, I have to find it in the dropdown list. When found, I can select it..
    Took me a while to figure this out ….

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.