skip to Main Content

I wrote following scr but my form field is still empty.

     function callme(e) {
        let today = new Date();
            document.getElementById('dtCikisTarih').value = today;                  
    }

My form field has a specific definition as

      <asp:Button ID="btnAktar" runat="server" Text="Aktar" CommandName="AktarRow"  class = "inp" OnClientClick="return callme(this)"  />

              <iskurDateTimeBoxes:IskurDateBox ID="dtGirisTarih" runat="server" clientidmode="static"/>
              <iskurDateTimeBoxes:IskurDateBox ID="dtCikisTarih" runat="server" clientidmode="static"/>

2

Answers


  1. Chosen as BEST ANSWER

    This code solved the problem:

           function callme(e) {
    
                var tds = e.parentNode.parentNode.getElementsByTagName('td');
    
                document.getElementById('txtFirmaAdi').value = tds[2].innerHTML.trim();              
                var txtBxs = document.getElementsByClassName('TXT');
                    
                txtBxs[8].value = tds[6].innerHTML.trim().replace('&nbsp;','');
                txtBxs[9].value = tds[7].innerHTML.trim().replace('&nbsp;', '');           
            }
    

  2. to set the date field in javascript
    your code should be like this

        let today = new Date();
        
        // Format the date as needed (YYYY-MM-DD)
        let formattedDate = today.toISOString().substr(0, 10);
    
        // Set the value of the input field
        document.getElementById('dtCikisTarih').value = formattedDate;
    
    

    issue with setting the date value directly as a Date object. You need to format the date as a string in the appropriate format that the input field expects

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search