Jump to content

s_avinash_s

Members
  • Posts

    121
  • Joined

  • Last visited

Posts posted by s_avinash_s

  1. Hi

    I have created a sample project with user name and password.

    As shown in attached image, three and four are disabled.

    When i click on three or four buttons which are disabled, Is it possible to get alert with login and password.

    
    <html>
    <head>
    <script>
    function one()
    {document.getElementById("fir")
    alert("first button");
    }
    
    function two()
    {document.getElementById("sec")
    alert("second button");
    }
    
    function three()
    {document.getElementById("thi")
    alert("third button");
    }
    
    function four()
    {document.getElementById("for")
    alert("fourth  button");
    }
    function login()
    {
    var password=["1234", "5678"];
    var username=["abcd","defg"];
    var uid=document.getElementById("uname").value;
    var pid=document.getElementById("pass").value;
    
    if(password[0] == pid && username[0] == uid){
    
    document.getElementById("fir").disabled = false;
    document.getElementById("sec").disabled = false;
    document.getElementById("thi").disabled = false;
    document.getElementById("for").disabled = false;
    }
    else if(password[1] == pid && username[1] == uid) {
    alert("Success");
    document.getElementById("thi").disabled = true;
    document.getElementById("for").disabled = true;
    }
    else
    {
    alert ("Enter valid username and password");
    document.getElementById("fir").disabled = true;
    document.getElementById("sec").disabled = true;
    document.getElementById("thi").disabled = true;
    document.getElementById("for").disabled = true;
    }
    }
    </script>
    </head>
    <body>
    
      <label for="uname"><b>Username</b></label>
        <input type="text" id="uname" placeholder="Enter Username" name="uname" required><br/><br/>
    	
    	<label for="psw" ><b>Password</b></label>
        <input type="password" placeholder="Enter Password" id="pass" name="psw" required><br/><br/>
    
        <button onclick="login()" id="log">Login</button><br/><br/><br/>
    	
    	<button onclick="one()" id="fir">one</button>
    	<button onclick="two()" id="sec">two</button>
    	<button onclick="three()"id="thi">three</button>
    	<button onclick="four()" id="for">four</button>
    	
    </body>
    </html>

     

    Capture11.PNG

  2. Hi

    Just the position of " error_prev=error_case;" is changed

    and now i corrected the setinterval 

    <script>
    function error_8() {
            var x8;
          var xhttp = new XMLHttpRequest();
          xhttp.onreadystatechange = function() 
          {
                if(xhttp.readyState == 4) 
                {
                    if(xhttp.status == 0) 
                    {      
                       
                       
                    }
                    else 
                    {                        
                        x8 = this.responseText; 
                                            
                        if (x8 == 0 )
                         {
                            document.getElementById("error_pos8").value = "Under Pressure";
                            error_case = document.getElementById("error_pos8").value; 
                            
                         }
                         
                    }
                }       
          };
        xhttp.open("GET", "error_val8.txt", true);
        xhttp.send();
        }
    
        setInterval(error_8(), 1000);
        
        
        var error_case,error_prev;
        function temp1() {
        var list = document.getElementById("myList");
        if(error_prev!==error_case)
        {
        list.removeChild(list.children[4]);
        var newItem = document.createElement("LI");   
        var textnode = document.createTextNode(error_case);
        newItem.appendChild(textnode);
        list.insertBefore(newItem, list.children[0]);
        }
          error_prev=error_case;
    }
    setInterval(temp1,1000);
        
        </script>

     

  3. Hi

    Changed like below.

    At the end error_prev am updating..

    still same issue..nothing appears

    if(error_prev!==error_case)
        {
        list.removeChild(list.children[4]);
        var newItem = document.createElement("LI");   
        var textnode = document.createTextNode(error_case);
        newItem.appendChild(textnode);
        list.insertBefore(newItem, list.children[0]);
        }
        error_prev=error_case;

     

  4. Hi

    I changed like below.

    <script>
    function error_8() {
            var x8;
          var xhttp = new XMLHttpRequest();
          xhttp.onreadystatechange = function() 
          {
                if(xhttp.readyState == 4) 
                {
                    if(xhttp.status == 0) 
                    {      
                       
                       
                    }
                    else 
                    {                        
                        x8 = this.responseText; 
                                            
                        if (x8 == 0 )
                         {
                            document.getElementById("error_pos8").value = "Under Pressure";
                            error_case = document.getElementById("error_pos8").value; 
                            error_prev=error_case;
                         }
                         
                    }
                }       
          };
        xhttp.open("GET", "error_val8.txt", true);
        xhttp.send();
        }
    
        setInterval(error_8(), 1000);
        
        
        var error_case,error_prev;
        function temp1() {
        var list = document.getElementById("myList");
        if(error_prev!==error_case)
        {
        list.removeChild(list.children[4]);
        var newItem = document.createElement("LI");   
        var textnode = document.createTextNode(error_case);
        newItem.appendChild(textnode);
        list.insertBefore(newItem, list.children[0]);
        }
    }
    setInterval("temp1()",1000);
        
        </script>

    I have similar functions from error_1 to error_8

    error_prev=error_case; is present in all 8 functions

    i tried above but its not working

  5. Hi

    This works fine.

    Am receiving the data from server using ajax every 1 sec.

    I need to avoid if same data is appearing, i mean only when different data appears.i need to delete child[4] and display the new data  at child[0] position.

    so i tried this way.will this work

    AJAX:
    
    if (x8 == 0 )
                         {
                            document.getElementById("error_pos8").value = "Under Pressure";
                            error_case = document.getElementById("error_pos8").value; 
                         }
    
    
    INSERTBEFORE:
    if(error_case!=document.createTextNode(error_case))
    {
        newItem.appendChild(textnode);  
        list.insertBefore(newItem, list.children[0]);
    }

     

  6. Hi

    I am trying the simple method by referring w3schools

    <!DOCTYPE html>
    <html>
    <body>
    
    <ul id="myList">
      <li>Coffee</li>
      <li>Tea</li>
      <li>milk</li>
      <li>complan</li>
      <li>boost</li>
    </ul>
    
    
    <button onclick="myFunction()">Try it</button>
    
    
    
    <script>
    function myFunction() {
    
        var list = document.getElementById("myList");
    	list.removeChild(list.childNodes[4]);
        var newItem = document.createElement("LI");   
        var textnode = document.createTextNode("Water");
        newItem.appendChild(textnode);
        list = document.getElementById("myList");
        list.insertBefore(newItem, list.childNodes[0]);
    }
    </script>
    
    </body>
    </html>

    1.My intention is to remove the last element 

    2.then add "water " to first line using insert before

    Need to do it in same function, one should delete and other to add after deleting.

    But this is not working

    anything wrong here

  7. Hi

    Am using below example for insertbefore method

     

     <p   id="error_pos8"></p>
    
     <ul id="alerts_errors_list">
    
    </ul>
    <script>
    function error_8() {
            var x8;
          var xhttp = new XMLHttpRequest();
          xhttp.onreadystatechange = function() 
          {
                if(xhttp.readyState == 4) 
                {
                    if(xhttp.status == 0) 
                    {      
                        document.getElementById("error_pos8").innerHTML = this.responseText;
                       
                    }
                    else 
                    {                        
                        x8 = this.responseText; 
                                            
                        if (x8 == 0 )
                         {
                            document.getElementById("error_pos8").innerHTML = "Under Pressure";
                            error_case = document.getElementById("error_pos8").innerHTML; 
                         }
                         
                    }
                }       
          };
        xhttp.open("GET", "error_val8.txt", true);
        xhttp.send();
        }
    
        setInterval(error_8(), 1000);
        
        
        var error_case;
        function alerts_errors() {
        var newItem = document.createElement("LI");
        var textnode = document.createTextNode(error_case);
        newItem.appendChild(textnode);
    
        var list = document.getElementById("alerts_errors_list"); 
        list.style.color = "red";
        list.insertBefore(newItem, list.childNodes[0]);
    }
    setInterval("alerts_errors()",100000);
        
        </script>

    whether the below code works fine for insertbefore ,because i have similar code for 8 other error list

    x8 = this.responseText; 
                                            
                        if (x8 == 0 )
                         {
                            document.getElementById("error_pos8").innerHTML = "Under Pressure";
                            error_case = document.getElementById("error_pos8").innerHTML; 
                         }

    so now error case should be printed only when it satisfies the x1==0  to x8==0 condition

    Will it be fine

  8. Hi

    with that i am able to do it.

    Now it works.

    But am deleting a file , by using a delete button.

    How to clear the before read data present  in textarea to get clear when delete button is clicked

             
    <textarea id="eventlogview1" rows="4" cols="50">
    </textarea>
    
    <button onclick="Eventlogdelete()">Delete Event log</button>

     

  9. Hi 

    I have a web page with data transfer between server and client.

    I have no much idea about xml file creation.

    My requirement is, the data whichever is changed needs to be saved in xml file  as a storage.

    How to create a simple xml file and save a data to it, so that same xml  file (which has settings) can be used for other similar server and client 

     

  10. Hi

    Thanks for the reply.

    <p id="logview"></p>
    
      <script>
    function logview() {
    
          var xhttp = new XMLHttpRequest();
          xhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) { 
    	      
              document.getElementById("logview1").value = this.responseText;           
            }
          };
        xhttp.open("GET", "log1.txt", true);
        xhttp.send();
        }
        </script>
    
    <button onclick="logview()">View the log</button>

    I am using above code , i have a data in log1.txt file.

    How can i display the data in log1.txt file into " textarea".

    Please suggest

  11. Hi 

    I am using a input text ., am getting a data from a text file from sd card and trying to print in a text box using onclick event.

    <!DOCTYPE html>
    <html>
    <body>
    
    <form action="/action_page.php">
    First name: <input type="text" name="FirstName" value="ABCD
    ABCD
    1234
    wert
    2345
    9988
    12345678
     
    " size="100" style="height:200px;font-size:14pt; overflow: scroll;"><br>
    
    <input type="submit" value="Submit">
    </form>
    
    
    </body>
    </html>

    My text file has similar data s mentioned in "value".I mean data is in different line but my output is in single line shows as  in attached image.

    1. my requirement is, to get the data exactly as in file(line by line) or as mentioned in value

    2.i need a scroll option when data exceeds

    output.PNG

  12. Hi

    this.responseText;

    is the value always received from server and it is incremented always.

    so am checking alert condition based on this value increment.

    As of now 'systemp_pos1.txt' dont have a data in it. it is just for receiving at server as action=/systemp_pos1.txt

    How to proceed 

  13. Hi

    I am checking a value of a variable continuously,if the value exceeds 44 then i should popup an alert  window.

    I tried the below code but its not working

    <p class = "modify" id="systemp_pos"></p>
        
        <script>
        var sys_1;
        function systemp() {
    
          var xhttp = new XMLHttpRequest();
          xhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) { 
    	      document.getElementById("systemp_pos").innerHTML = this.responseText; 
                sys_1=this.responseText; 
                if(sys_1 > 44 )
                {
                alert("system temperature is increased");
                }
            }
          };
        xhttp.open("GET", "systemp_pos1.txt", true);
        xhttp.send();
        }
    
        setInterval(systemp, 1000);
        </script>

    Please suggest

  14. Hi

    when i use like below .am not getting

    <div id="DateTimeSettings" onclick="auto_time()"  class="tabcontent1">   
        
        <br>
     <input type="hidden" id="automatic">  
     <form action="/automatic.txt" method="post">
    <input type="text" id="automatic1" size="40" name="fname" style="border: 2px solid black;font-size:15pt;" >
    <input type="submit" value="submit">  
    </form>
          </div>
          <script>
          function auto_time() {
    var d = new Date();
    document.getElementById("automatic").value = d;
    document.getElementById("automatic1").value = d;
    }

    Instead if i keep 

    <button onclick="auto_time()">Click me</button>

    i get the time updated.

    Is it possible to do with using id="DateTimeSettings"

  15. Hi

    I have modified the code as below

        <div id="DateTimeSettings" class="tabcontent1">   
      <input type="hidden" id="automatic">  
    <input type="text" id="automatic1" size="40" style="border: 2px solid black;font-size:15pt;" readonly >
          </div>
          <script>
          function auto_time() {
    var d = new Date();
    document.getElementById("automatic").value = d;
    document.getElementById("automatic1").value = d;
    }

    Now i get the data in box and then i have a junk characters as shown in attached image.

    2.One more need is, i have a tab with id = "DateTimeSettings" .The date should update on;y when i click that particular  tab.

    3. I need to use form method =post for submitting it.How to use it

    How ca i do it, please help

    Capture7.PNG

    Capture8.PNG

  16. Hi

    I am getting a time from PC .I have a tab with id "DateTimeSettings".

     

        <div id="DateTimeSettings" class="tabcontent1">
        
        
      <div id="automatic">  
    <script>      
    function auto_time() {
    var d = new Date();
    document.getElementById("automatic").value = d;
    document.getElementById("automatic1").value = d;
    }
    
    </script>
    
    <input type="text" id="automatic1" size="11" style="border: 2px solid black;font-size:15pt;" readonly >
    </div>
          </div>

    My need is , whenever i open that tab i need a updated time in my text box as mentioned below.

    <input type="text" id="automatic1" size="11" style="border: 2px solid black;font-size:15pt;" readonly >

     

    How to get it, am always getting a empty value.

    Please suggest

  17. Hi 

    I have a table , In first column i need to update a dynamic data in rotating format  for 5 values every 1 sec.

    I mean like, for 1 sec temp1 will be displayed, for next  second temp2 should be dispalyed,

    for thirs second, temp3 should be displayed  etc.

    How to proceed with this

  18. Hi

    My code i have kept in https://www.w3schools.com/code/tryit.asp?filename=FW56M9QG79H1

    I need to get a continuous data from server and update it, so i am using AJAX.

    If the code enters error condition, then only fresh error should be displayed on first line else previous error will be on first line.

    when fresh error is on first line , other error should shift to second line and so on till 5 errors.(only 5 errors are required).

    It is like bottleneck for me, please help

     

×
×
  • Create New...