Jump to content

s_avinash_s

Members
  • Content Count

    116
  • Joined

  • Last visited

Community Reputation

0 Neutral

About s_avinash_s

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. s_avinash_s

    function call not executing

    Hi Actually i tried from https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_objects there that function is defined . similar way i tried with btn.onclick = function() { But login related part works if i directly assign a value to variable in html code but does not work when i get a value from server and click the particular tab
  2. s_avinash_s

    function call not executing

    Hi I tried with following example var btn = document.querySelector('button'); function bgChange() { var rndCol = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')'; document.body.style.backgroundColor = rndCol; } btn.addEventListener('click', bgChange); but still its same. If i give user_login=1 in html file it works fine. Please help am not exactly getting what is the issue
  3. s_avinash_s

    function call not executing

    Hi i did not get what exactly is causing the mismatch for functions. Its not working . How to use event , still not getting
  4. s_avinash_s

    function call not executing

    Hi I dont have much idea about event, i have just used a direct code from w3schools for tab creation. Can you please help me, how to use event and how to define in mycode so that it calss the function correctly./
  5. s_avinash_s

    function call not executing

    Hi Below is my source code.Is there any mismatch between the calling function and function definition. Please suggest <form class ="language_home" action="/passwordcheck.txt" method="post">       Login: <select name='userchoice' > <option value="1">User</option> <option value="2">Supervisor</option> <option value="3">Admin</option> <option value="4">Service</option> </select> Password: <input type="password" name="pwd" > <button id="log">Login</button><br/><br/><br/> </form> <script> var user_login; var supervisor_login; var admin_login; var service_login; var a; var b; var c; var d; var tablinks = document.getElementsByClassName("tablinks"); var tabcontent = document.getElementsByClassName("tabcontent"); if (localStorage.activeLI) { tablinks[localStorage.activeLI].className += " active"; tabcontent[localStorage.activeLI].style.display = "block"; } function openCity(evt, cityName) { var i; for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(cityName).style.display = "block"; evt.currentTarget.className += " active"; for (i = 0; i < tablinks.length; i++) { if (tablinks[i].className.indexOf("active") !== -1) { localStorage.activeLI = i; } } } function func() { document.getElementById('id01').style.display='block'; } function flva() { if(a == 1 || b == 1 || c == 1 || d == 1) { openCity(event, 'temp1'); } else { func(); } } function stgt() { if(a == 1 || b == 1 || c == 1 || d == 1) { openCity(event, 'temp2'); } else { func(); } } function prvar() { if(a == 1 || b == 1 || c == 1 || d == 1) { openCity(event, 'temp3'); } else { func(); } } function tot() { if(a == 1 || b == 1 || c == 1 || d == 1) { openCity(event, 'temp4'); } else { func(); } } function inot() { if(a == 1 || b == 1 || c == 1 || d == 1) { openCity(event, 'temp5'); } else { func(); } } function comsg() { if(a == 1 || b == 1 || c == 1 || d == 1) { openCity(event, 'temp6'); } else { func(); } } function caltn() { if(a == 1 || b == 1 || c == 1 || d == 1) { openCity(event, 'temp7'); } else { func(); } } function dgst() { if(a == 1 || b == 1 || c == 1 || d == 1) { openCity(event, 'temp8'); } else { func(); } } function user_option() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { user_login=parseInt(this.responseText); if(user_login==1) { a=1; } else { a=0; } } }; xhttp.open("GET", "user_login.txt", true); xhttp.send(); } setInterval(user_option, 1000); function supervisor_option() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { supervisor_login=parseInt(this.responseText); if(supervisor_login==1) { b=1; } else { b=0; } } }; xhttp.open("GET", "supervisor_login.txt", true); xhttp.send(); } setInterval(supervisor_option, 1000); function admin_option() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { admin_login=parseInt(this.responseText); if(admin_login==1) { c=1; } else { c=0; } } }; xhttp.open("GET", "admin_login.txt", true); xhttp.send(); } setInterval(admin_option, 1000); function service_option() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { service_login=parseInt(this.responseText); if(service_login==1) { d=1; } else { d=0; } } }; xhttp.open("GET", "service_login.txt", true); xhttp.send(); } setInterval(service_option, 1000); </script>
  6. s_avinash_s

    function call not executing

    Hi 4 statements i have modified as mentioned. event is used in tabs script <script> function openCity(evt, cityName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(cityName).style.display = "block"; evt.currentTarget.className += " active"; } </script> But i dont understand why this function call is not execuitng
  7. s_avinash_s

    getting dynamic data for one tab only

    Hi Just got some idea about json objects <p id="demo"></p> <script> var myObj, x; myObj = {"name":"John", "age":30, "car":null}; x = myObj.name; document.getElementById("demo").innerHTML = x; </script> but in ajax am receiving data till now as below if (this.readyState == 4 && this.status == 200) { document.getElementById("demo2").innerHTML = this.responseText; } Now how to get data through ajax and json object. My plan is to receive like below else if ((NX_HTTP_SERVER_GET_REQUEST == request_type) && (0 == strcmp (resource, "/tab1"))) { while(i < number) { memset (g_str_buf, 0, sizeof(g_str_buf)); snprintf (g_str_buf, STR_BUFFER_LEN, "%s", variable[number]); nx_http_server_callback_data_send (server_ptr, g_str_buf, sizeof (tab1)); return (NX_HTTP_CALLBACK_COMPLETED); } } How to get it , still its not clear to me
  8. s_avinash_s

    function call not executing

    Hi Function call is not happening. i have 7 tabs in my code based on following example https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_tabs Before the tabs are created i have a common section in my web page where it is accessible from any tab.I mean after this section, tabs code comes. So before tabs code is called am calling a function function openCity(evt, cityName) which uses script of tabs code but that script is not being called. My code where function call is not executing is function def() { if(temp1 == 1) { openCity(event, 'temperature'); } else if(temp2 == 1) { openCity(event, 'temperature'); } else if(temp3 == 1) { openCity(event, 'temperature'); } else if(temp4 == 1) { openCity(event, 'temperature'); } else { func(); } } In above code, temperature is a tab name which should open that tab only when the above conditions satisfy but it does not work. Any thing wrong with my call
  9. s_avinash_s

    getting dynamic data for one tab only

    Hi From above i am planning to get whole data to web page( i need to test). Once i get whole data to web page, how to place each data in its specified location in web page
  10. s_avinash_s

    getting dynamic data for one tab only

    Hi Usually i use ajax to get data every 1 sec for a particular variable as shown below and call that function using setInterval. <p class = "modify" id="demo11"></p> <script> function temp_val() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("demo11").innerHTML = this.responseText; } }; xhttp.open("GET", "temp_val", true); xhttp.send(); } setInterval(temp_val, 1000); </script> For tab creation , i followed a example from https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_tabs Onclick functionality if i use, then i send to server with that tab name ,..example tab1 xhttp.open("GET", "tab1", true); and from server all the variables of that tab can be placed and receives at web page.Some thing similar to below if i use else if ((NX_HTTP_SERVER_GET_REQUEST == request_type) && (0 == strcmp (resource, "/tab1"))) { memset (g_str_buf, 0, sizeof(g_str_buf)); snprintf (g_str_buf, STR_BUFFER_LEN, "%d", temp_val); nx_http_server_callback_data_send (server_ptr, g_str_buf, sizeof (tab1)); return (NX_HTTP_CALLBACK_COMPLETED); } How to differentiate and keep each variable in required text box after reeving since i will be having a 50 to 100 variables update. Hope you have understood my requirement
  11. s_avinash_s

    onclick disabled button

    Hi Not replacing alert with figure. i need a alert with username , password and login option. For example, if you check this example https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_alert it displays a alert with "Hello! I am an alert box!". Similarly i need a alert with username , password and login option.
  12. s_avinash_s

    onload event

    Hi Thanks for the info. I got some info about addeventlistener and tried the following code. when i click button it displays the value. Without clicking, is it possible to load the value only once. <!DOCTYPE html> <html> <body> <button id="myBtn">Try it</button> <p id="demo"> <script> var x=100; document.getElementById("myBtn").addEventListener("click", myFunction); function myFunction() { document.getElementById("demo").innerHTML = x; } </script> </body> </html>
  13. s_avinash_s

    onload event

    Hi I have a code where 3 onload functions are being used. but only first one displays in text box and other 2 not displaying. I am not getting what is wrong <body onload="abc()"> </body> <script> function abc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("temp1").value = this.responseText; } }; xhttp.open("GET", "temp1", true); xhttp.send(); } </script> <br> <br> <h3>SW version: <input type="text" id="temp1" size ="10" style="border:none;font-size:27pt;"></h3> <body onload="def()"> <script> function def() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("temp2").value = this.responseText; } }; xhttp.open("GET", "temp2", true); xhttp.send(); } </script> </body> <h3>HW version: <input type="text" id="temp2" size ="10" style="border:none;font-size:27pt;"></h3> <br> <body onload="ghi()"> </body> <script> function ghi() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("temp3").value = this.responseText; } }; xhttp.open("GET", "temp3", true); xhttp.send(); } </script> <h3>Version Info: <input type="text" id="temp3" size ="10" style="border:none;font-size:27pt;"></h3> <br>
  14. s_avinash_s

    getting dynamic data for one tab only

    Hi I have 7 to 8 tabs in my code and interacting to server using ajax for getting dynamic data every 1 sec. Since am requesting more data every 1 sec it is slowing down the content and it lags. So is it possible to update only that tab which user clicks.I mean among 7 to 8 tabs user cant view all tabs at the same time. So he views one by one based on his requirement. So how to make only the clicked tab to get dynamic data. Please suggest
  15. s_avinash_s

    onclick disabled button

    Hi Both the codes which were posted were helpful. Now i get a alert saying "third button" etc. So instead of that alert, i need to replace alert with login option as shown in figure. Please suggest
×