Jump to content

ravi_k

Members
  • Posts

    18
  • Joined

  • Last visited

Everything posted by ravi_k

  1. Hi I am using ajax to get the data received at server side . In the below mentioned link,It is mentioned that: The onreadystatechange event is triggered four times (1-4), one time for each change in the readyState. https://www.w3schools.com/js/js_ajax_http_response.asp In my case, some times the data is received 2 or 3 times when am sending it only once. How to receive data only once.Please suggest Thanks and Regards Ravi K
  2. Hi Guys, How to get NTP server time using HTML? Can anyone share a example for getting NTP Server time using HTML? Thanks with Regards Ravi K
  3. Hi How can i access sd card files present in MCU from web server? I tried the below method but the browse button takes to PC browse instead of SD card in MCU. <form action="/upload" id="upload" method="post"> <input type="file" id="fileupload" name="myfile"> <input type="submit" value="submit" id="submit" > </form> Please help Thanks with Regards Ravi K
  4. Hi I am using prevent default to restrict the submitted data posting on other page. It works fine but i try to call other function also with onsubmit to get a alert from server after submitting it. In below onsubmit am calling 2 functions, only one works. <form name="myForm0" action="/volumeflow" method="post" autocomplete="off" id="vlmn" target="formDestination" onsubmit="return volflow12(event); volflow_check()"> But it does not work. I tried with onsubmit and onclick. What is the issue <script > function volflow_check() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { alert("volume flow submitted successfully"); } }; xhttp.open("GET", "volumeflow_check", true); xhttp.send(); } function volflow12(event) { var w = document.forms["myForm0"]["damping0"].value; var x = document.forms["myForm0"]["flowcutoff0"].value; var z = document.forms["myForm0"]["decimal0"].value; if (w == "") { alert("Field 1 must be filled out"); return false; } else if (x == "") { alert("Field 2 must be filled out"); return false; } else if (z == "") { alert("Field 3 must be filled out"); return false; } else { myFunctionabcd33(event); } } function showForm2() { var selopt =document.getElementById("optsv").value; if (selopt == 1) { document.getElementById("f3").style.display = "inline"; document.getElementById("f4").style.display = "none"; } else if (selopt == 2) { document.getElementById("f4").style.display = "inline"; document.getElementById("f3").style.display = "none"; } else { document.getElementById("f4").style.display = "none"; document.getElementById("f3").style.display = "none"; } } function myFunctionabcd33(event) { var myForm = document.getElementById('vlmn'); event.preventDefault(); formData = new FormData(myForm); var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("vlmn").innerHTML = this.responseText; } }; xhttp.open("POST", "volumeflow",true); xhttp.send(formData); return true; } </script> <form name="myForm0" action="/volumeflow" method="post" autocomplete="off" id="vlmn" target="formDestination" onsubmit="return volflow12(event); volflow_check()"> <label>Volume Flow Unit Selection:</label> <select id='optsv' name='Selectunit' onchange="showForm2()"> <option value="0">Select Option</option> <option value="1">SI units</option> <option value="2">US units</option> </select> <div id="f3" style="display:none"> <select id='opt3' name='SIunits' onchange="showForm2()"> <option >Select</option> <option value="0">Lit/Sec</option> <option value="1">Lit/min</option> <option value="2">Lit/hr</option> <option value="3">Lit/day</option> </select> </div> <div id="f4" style="display:none"> <select id='opt4' name='USUnits' onchange="showForm2()"> <option >Select</option> <option value="0">Gal/min</option> <option value="1">Gal/hr</option> <option value="2">Gal/Sec</option> <option value="3">Gal/day</option> </select> </div> <br> <br> <label> Volume Flow Damping:</label> <input type="text" name="damping0" size="10"> <br><br> <label> Volume Flow Cutoff:</label> <input type="text" name="flowcutoff0" size="10"> <br><br> <label> Volume Decimal Places:</label> <input type="text" name="decimal0" size="10"> <br><br> <span style="margin-right:24.5%;"></span> <input type="submit" value="Submit"> </form> Please suggest , why two functions are not able to call Thanks with Regards Ravi
  5. Hi I am not receiving any value. To check if am getting any value , i am just getting a value and try to print it in a text box But nothing prints. I think some issue is there <p id ="sensor_progress"></p> <div> <button onclick="Sensor()">Sensor</button> &emsp;&emsp;&nbsp;&nbsp; <progress id="myProgress" value="22" max="100"> </progress> <input type="text" id="sensor_progress" size ="7"style="border: 2px solid black;font-size:20pt;" disabled> <script> function Sensor() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("myProgress").value =this.responseText; document.getElementById("sensor_progress").value = this.responseText; } }; xhttp.open("GET", "sensor.txt", true); xhttp.send(); } </script> Thanks with Regards Ravi
  6. Hi Whether the calling of document.getElementById("myProgress").value =this.responseText; is proper or not? May be its not receiving the value properly. Thanks with Regards Ravi
  7. Hi I have a below code, which shows a progress bar. default it shows as 22. but when i receive the data from server , the progress bar data should be changed. <div> <button onclick="Sensor()">Sensor</button> <progress id="myProgress" value="22" min="0"max="100"> </progress> </div> <script> function Sensor() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("myProgress").value = this.responseText; } }; xhttp.open("GET", "sensor", true); xhttp.send(); } </script> Thanks with Regards Ravi
  8. Hi If i don't send anything form server for the post request( using the earlier method of onclick), then the form is submitted and no data is received on client side except that client request is received 3 to 6 times continuously for 1 post request send.(here if i can avoid multiple requests , issue is solved) Above method suggested by Dsonesuk, i will try this once Thanks With Regards Ravi
  9. Hi With onsubmit, no value is received on server .nothing is sent by client. Thanks With Regards Ravi
  10. Hi Am using a post request. As suggested above am already using preventDefault() in my code using form data . <form action="/val" method="post" id="val" name="val" > Value:&emsp;<select name='val' > <option value="0">Zero</option> <option value="1">One</option> </select> <input type="submit" value="Submit" onclick="myFunction_value(event)"> </form> <script> function myFunction_value(event) { var myForm = document.getElementById('val'); event.preventDefault(); formData = new FormData(myForm); var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("val").innerHTML = this.responseText; } }; xhttp.open("POST", "val",true); xhttp.send(formData); return true; } </script> Thanks With Regards Ravi
  11. Hi guys How to submit a form using ajax without redirection to other page and stays on same page. Now redirection is not happening but i get the below message on client web page. Value selected : -----------------------------117571124310148 Content-Disposition: form-data; value="zero" 0 -----------------------------117571124310148-- Thanks With Regards Ravi
  12. Hi I have changed my code as below. <form action="/action_page.php" method="post"> Testing: &emsp;&nbsp;&nbsp;<input name="ip" id="ip" type="text" min="0" max="255"> <input type="submit" value="Start"> <input type="submit" value="Stop"> </form> How can i differentiate which button is pressed on server side whether its start or stop. Please suggest Thanks with Regards Ravi K
  13. Hi I am trying to submit the form and also when start is pressed, it should be disabled and only stop to be avialable. I tried below code but submit form is not happening <form action="/action_page.php" method="post"> Testing:   <input name="ip" id="ip" type="text" min="0" max="255"> <input type="submit" id="start" value="start" onclick="myFunction1()"> <input type="submit" id="stop" value="stop" onclick="myFunction2()"> </form> <script> function myFunction1() { document.getElementById("start").disabled = true; document.getElementById("stop").disabled = false; } function myFunction2() { document.getElementById("start").disabled = false; document.getElementById("stop").disabled = true; } </script> Thanks with Regards Ravi K
  14. Hi Thanks for the reply. Actually form action i have changed and method to post. here my problem is , when it sends to server as "List1=Apparel&List2=Men&List3=Shirts&List4=Tux " i am parsing the string using c code for alphabets..i remove all the alpahbets and =&.. so that only values are available and i can use it. for this multiple dropdown also, i need values so that i can parse alphabets. How to do it.Please help Thanks with Regards Ravi K
  15. Hi Now am able to submit it. But while submitting it shows output as List1=Apparel&List2=Men&List3=Shirts&List4=Tux instead how to link above code with values. I mean as List1=0&List2=1&List3=2&List4=3 Is there a way to link....but in array same names can be used as apparel men etc but while submit i need it as values..How to link it Please suggest Thanks with Regards Ravi K
  16. Hi I am new to HTMLprogramming I got some code online which has multiple dropdowns but when "show selections " is pressed.it alerts the selected items. My need is, it should submit all the selected items from dropdown <html> <head> <title> 1- to 4-level Drop Down</title> <style type="text/css"> .DDlist { display:none; } </style> <script type="text/javascript"> // From: http://www.codingforums.com/showthread.php?t=202456 // and: http://www.codingforums.com/showthread.php?t=169465 // Modified for 1 to 4 (+) level drop down selections var categories = []; categories["startList"] = ["Apparel","Books",'Radio','True','False']; // Level 1 (True|False is 1 level only) categories["Apparel"] = ["Men","Women"]; // Level 2 categories["Men"] = ["Shirts","Ties","Belts"]; // Level 3 categories['Shirts'] = ['Tux','Button-down','Polo',"T's"] // Level 4 categories['Ties'] = ['Silk','String','Bow'] // Level 4 categories['Belts'] = ['Leather','Cloth'] // Level 4 categories["Women"] = ["Blouses","Skirts","Scarves"]; // Level 3 categories["Blouses"] = ["Silk","Cotton","Polyester"]; // Level 4 only categories["Skirts"] = ["Full","Pleated"]; // Level 4 only categories["Scarves"] = ["Head","Neck","Waist"]; // Level 4 only categories["Books"] = ["Biography","Fiction","Nonfiction"]; // Level 2 categories["Biography"] = ["Contemporary","Historical","Other"]; // Level 3 only categories["Fiction"] = ["Science","Romance"]; // Level 3 only categories["Nonfiction"] = ["How-To","Travel","Cookbooks"]; // Level 3 only categories['Radio'] = ['AM','FM','HD']; // Level 2 only var nLists = 4; // number of lists in the set function fillSelect(currCat,currList){ var step = Number(currList.name.replace(/\D/g,"")); for (i=step; i<nLists+1; i++) { document.forms[0]['List'+i].length = 1; document.forms[0]['List'+i].selectedIndex = 0; document.getElementById('List'+i).style.display = 'none'; } var nCat = categories[currCat]; if (nCat != undefined) { document.getElementById('List'+step).style.display = 'inline'; for (each in nCat) { var nOption = document.createElement('option'); var nData = document.createTextNode(nCat[each]); nOption.setAttribute('value',nCat[each]); nOption.appendChild(nData); currList.appendChild(nOption); } } } function getValues() { var str = ''; str += document.getElementById('List1').value+'\n'; for (var i=2; i<=nLists; i++) { if (document.getElementById('List'+i).selectedIndex != 0) { str += document.getElementById('List'+i).value+'\n'; } } alert(str); } function init() { fillSelect('startList',document.forms[0]['List1']); } navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false); </script> </head> <body> <form action="" onsubmit="return false"> <select name='List1' id="List1" onchange="fillSelect(this.value,this.form['List2'])"> <option selected>Make a selection</option> </select> &nbsp; <select name='List2' id="List2" onchange="fillSelect(this.value,this.form['List3'])" class="DDlist"> <option selected>Make a selection</option> </select> &nbsp; <select name='List3' id="List3" onchange="fillSelect(this.value,this.form['List4'])" class="DDlist"> <option selected >Make a selection</option> </select> &nbsp; <select name='List4' id="List4" class="DDlist"> <option selected >Make a selection</option> </select> &nbsp; <!-- can add more levels if desired as "List5"+ --> <button onclick="getValues()">Show selections</button> </form> </body> </html> How to modify it .Please suggest Thanks with regards Ravi K
  17. Hi Guys, I tried the following method for vertical tabs. https://www.w3schools.com/code/tryit.asp?filename=FW6W3MNG90NC When i click parent tab, i need the child tabs to be in same size as parent tab but it is different in size. How to avoid it, is there any example Thanks with Ravi
  18. Hi guys, how to get nested vertical tabs (one under one). Thanks With Regards Ravi
×
×
  • Create New...