0

I want to set the value of textbox to my dropdown box first attempt.....I want whenever my textbox value should change it should get the value of dropdown and display at dropdown box.

I want whatever the value is coming in my textbox from tablelist should display in my dropdown box as default value...

Please help.

I tried this :

 $("#editdevicetype").wijcombobox({
    data : datasources,
    showTrigger : true,
    changed:function(e, data) {
        dtype =data.selectedItem.value;
        $('#deviceType1').val(dtype);   

        //document.getElementById("editdevicetype").value=dtype;
        dttype =data.selectedItem.value;
        $('#editdevicetype').val(dttype);
        $('#editdevicetype').val($('#deviceType1').val());
    }
}); 

My table Code : currentCellChanging: function (e, args) {

$("#devicelist").wijgrid(
{
  allowSorting: true,
 allowColSizing: true,

 dtype=data[selRow].DeviceType;
                                              document.getElementById("deviceType1").value=dtype;
                                            //dttype=data.label;
                                            document.getElementById("editdevicetype").value=dtype.replaceByValue(/[^>]+$/, dtype);
Tina
  • 25
  • 2
  • 10
  • What are your textbox and dropdown box ? – Calvein Aug 27 '12 at 10:19
  • @calvein : #editdevicetype this is dropdown and #deviceType1 this is textbox .....I have done with when selecting dropdown value,textbox value will automatically change.....but I want reverse option when my text box value will change dropdown box should display textbox value also.... – Tina Aug 27 '12 at 10:25
  • What is a `tablelist`? How is the value in the `tablelist` being set to your textbox? If your own js code is doing that, then you can simply trigger the change event after the value has been set. – Amith George Aug 27 '12 at 10:59
  • @Tina I mean, what is a textbox and a dropdown in HTML, their is no such elements. – Calvein Aug 27 '12 at 12:05

1 Answers1

0

EDIT 1:

What is a tablelist? How is the value in the tablelist being set to your textbox? If your own js code is doing that, then you can simply trigger the change event after the value has been set.

// code from below to bind to the change event. 
// ...
// some code to set textbox value from tablelist. 
// ...
$('#deviceType1').change(); // this will trigger the change event. 
                            // ensure you have already bound to the change event.

You need to subscribe to events that will notify you when the text in the textbox has changed. Ideally that event should be the change event. You would write code as follows:

$('#deviceType1').change(function() {
    // value changed. write code to update the combox box.
});

However, the change event seems to fire only when the textbox looses focus. If that limitation is fine, then your problem is solved. However, if you want to catch the change occurring as it happens, then you will need to subscribe to a variety of events to handle both keyboard input and mouse input as well the case where the user might paste something into the textbox.

Here is an answer by @mdmullinax which suggests all possible events you could bind to, to handle the cases you need to support.

https://stackoverflow.com/a/6140270/30007 . Refer to the updated fiddle in his comments: http://jsfiddle.net/pxfunc/zJ7Lf/1/

Community
  • 1
  • 1
Amith George
  • 5,806
  • 2
  • 35
  • 53
  • :I want whatever the value is coming in my textbox from tablelist should display in my dropdown box as default value.... – Tina Aug 27 '12 at 10:55
  • No .....actually I have created one text box and one dropdown inside grid (initial value of dropdown box is null)...I have a details button in grid when smone hit on details its shows all the values now I want when smone hit details its show dropdown value also and I have the code this code to get the value now I want to replace code with value...please help document.getElementById("editdevicetype").value=dtype – Tina Sep 04 '12 at 11:36