In my table have dropdown. How to get text from dropdown?

In my table have dropdown. How to get text from dropdown?

whitewizardwhitewizard Posts: 12Questions: 0Answers: 0
edited May 2010 in General
I'm beginner. This is my code
[code]



My Topic






Test1
Test2















[/code]

I want to click on button (id=bt). then get text from any objects in table
So. my question is...
How to get text from textbox (id=mytxbox) and dropdown (id=combobox)? and
How to implement function "getDetail()"?
Please help me. Thanks

Replies

  • whitewizardwhitewizard Posts: 12Questions: 0Answers: 0
    Please let me know. How to get text from textbox? and How to get selected value?
  • chandruchandru Posts: 17Questions: 0Answers: 0
    Hi,
    Use this code,
    $('td select', this).change( function () {
    alert($(this).val());
    });
  • whitewizardwhitewizard Posts: 12Questions: 0Answers: 0
    Thanks chandru..
    But i want to get text from all cells in a table when i click a button. do you have any idea?
  • chandruchandru Posts: 17Questions: 0Answers: 0
    Hi,
    Use the below code.
    var aPos = oTable.fnGetPosition(this);
    var aData = oTable.fnGetData( aPos[0] );
  • whitewizardwhitewizard Posts: 12Questions: 0Answers: 0
    thanks chandru..
    i see example of fnGetData at "http://datatables.net/api#fGetNodes"
    The example show how to get and set text to a cell.
    my problem is after i get text from a cell i must set text to a cell.. but in my cell . it's contain textbox. how i can set text in the textbox..
  • whitewizardwhitewizard Posts: 12Questions: 0Answers: 0
    i try to use this below code

    var row = oTable.fnGetData(0);
    alert(row[0]);

    it's get html code in a cell. such as the cell have a textbox.
    the alert function must show
    but i want to get "10" as a result. and want to set it to 20. Have any idea
  • codingavenuecodingavenue Posts: 22Questions: 0Answers: 0
    Hi,

    Try this

    $(row[0]).val('NEW VALUE');
  • chandruchandru Posts: 17Questions: 0Answers: 0
    Hi,
    Use this.

    $('textId').val() = "20";
  • chandruchandru Posts: 17Questions: 0Answers: 0
    Hi,
    Use this.

    $('textId').val() = "20";
  • whitewizardwhitewizard Posts: 12Questions: 0Answers: 0
    Thanks codingavenue & chandru..
    codingavenue.. i try your solution but not work.
    chandru.. Your solution is work! but i found a problem.. It can't set value to some object which are disappear in current page. Example.. i want to use below code
    $('textId').val() = "20";
    now current page is 1, but the object (textId) is appear in page number 2. the object not be set. Do you have any idea?
  • chandruchandru Posts: 17Questions: 0Answers: 0
    HI,
    Can you send your code me?
    I want to see your coding. After that I'll give suggestions.
  • whitewizardwhitewizard Posts: 12Questions: 0Answers: 0
    chandru. This is my code.
    [code]
    // Global Variable
    var oTable;
    var setTable;

    $(document).ready(function() {
    oTable = $('#tablesorter-detail').dataTable({
    "bJQueryUI": true,
    "sPaginationType": "full_numbers",
    "bSort": true,
    "aoColumns": [
    { "sSortDataType": "dom-text", "sType": "numeric" },
    { "sSortDataType": "dom-label", "sType": "numeric" },
    { "sSortDataType": "dom-label", "sType": "numeric" },
    { "sSortDataType": "dom-text", "sType": "numeric" },
    { "sSortDataType": "dom-text", "sType": "numeric" },
    { "sSortDataType": "dom-label", "sType": "numeric" },
    { "sSortDataType": "dom-label", "sType": "numeric" },
    { "sSortDataType": "dom-text", "sType": "th_date" },
    { "sSortDataType": "dom-text", "sType": "th_date" }
    ],
    "fnDrawCallback": function ( oSettings ) {
    // This function is AddRowGrouping

    if ( oSettings.aiDisplay.length == 0 )
    {
    return;
    }

    // Get Rows [Array]
    var nTrs = $('#tablesorter-detail tbody tr');
    var iColspan = nTrs[0].getElementsByTagName('td').length;
    var sLastGroup = "";
    for ( var i=0 ; i
  • whitewizardwhitewizard Posts: 12Questions: 0Answers: 0
    Now. function autoSetPromo is below code
    [code]
    function autoSetPromo{
    $("#branchId1").val('9999999999');
    }
    [/code]
    But if i change to below code
    [code]
    $("#branchId100").val('9999999999');
    [/code]
    It's not work.
  • chandruchandru Posts: 17Questions: 0Answers: 0
    Use like this,
    $('tr').click( function() {
    var oText = this.getElementByTag('input');
    for(int i=0;i<=oText.length-1;i++)
    {
    if(oText[i].type == 'text')
    {
    oText[i].value = '100';
    }
    }
    });
  • whitewizardwhitewizard Posts: 12Questions: 0Answers: 0
    thanks chandru.. But i don't want to change value by click on row. Do you have any idea if i want to click button then change textbox value on first row, third row and last row or specific row? Althought the row are hidden.
  • amjadkhanamjadkhan Posts: 1Questions: 0Answers: 0
    also, i have the same issue as i want to get textbox and dropdown values after loading page. but it returns previous control values not after changing text or dropdown value.
This discussion has been closed.