JSFiddle - React, Tailwind, and code Playground

by bthorn

HTML

<table>
    <tr>
        <td style="width:5px;">
            <input type="hidden" name="GridView1:_ctl2:hndTxtId" id="GridView1__ctl2_hndTxtId" value="3601">
        </td>
        <td style="width:50px;">	<span id="GridView1__ctl2_lblVehicle0">413</span>

        </td>
        <td style="width:5px;">
            <input type="button" id="GridView1__ctl2_AddButton0" name="GridView1:_ctl2:AddButton0" value="On" class="btn-blue" onclick="setDateTimeOn(this)">
        </td>
        <td style="width:150px;">
            <!-- <input id="GridView1__ctl2_txtStormTimeOn" type="text" name="GridView1:_ctl2:txtStormTimeOn" value="">--> <span id="GridView1__ctl2_lblStormTimeOn"></span>

        </td>
    </tr>
</table>

JavaScript

//  txtLevel1Issued.Text = DateTime.Now.ToString("M/d/yyyy HH:mm");

var date = new Date();
//alert((date.getMonth() + 1) + '-' + date.getDate() + '-' +  date.getFullYear());

//GridView1__ctl2_AddButton0
//GridView1:_ctl2:txtStormTimeOn

//09-11-2015 10:03

function setDateTimeOn(elm) {
    //    var span = document.getElementById('GridView1__ctl2_lblStormTimeOn');

    //while( span.firstChild ) {
    //    span.removeChild( span.firstChild );
    //}
    //span.appendChild( document.createTextNode("some new content") );

    var formattedDate = GetCurrentDateTime(); //get formatted date
    $(elm) //clicked button
    .parent("td") // container td
    .next() // next td
    //.find("input") // find child input
    .find("span")
        .text(formattedDate);
    //.val(formattedDate); //set date

    console.log(elm);
    var hdn = $(this).closest('tr').find('input[type="hidden"]').val();
    console.log(hdn);

}

//var t = new Date();
//alert(hours12(t));

function GetCurrentDateTime() {
    var now = new Date();
    var h12 = hours12(now);
    return (now.getMonth() + 1) + "-" + now.getDate() + "-" + now.getFullYear() + " "
    //+ now.getHours() + ":" 
    +
    h12 + ":" + now.getMinutes();
}


function hours12(date) {
    return (date.getHours() + 24) % 12 || 12;
}







function setDateTimeOnOLD(x) {



    //alert(x.id);   
    console.log(x.id);
    //$('#x.id').val(

    var re = /__(.+)_/;
    // your control name was used an as example:
    //var str = 'GridView1__ctl2_AddButton0';

    var str = x.id;
    var m;

    if ((m = re.exec(str)) !== null) {
        if (m.index === re.lastIndex) {
            re.lastIndex++;
        }
        // View your result using the m-variable.
        // m[0] == 'ctl2'

        //$('[id^=conditionValue]').each(function (y) {


        $("#GridView1" + m[0] + "txtStormTimeOn").val("whatever");


        var z = m[0].replace('__', '');
        var z = z.replace('_', '');
        console.log(z);
       ...