简体   繁体   中英

how to insert some variables into an html by attaching it the var at the end of html page

I am using a microcontroller and I'm communicating with it via a html page.

The pages are stored as some constant in the microcontroller and are sent to PC for display purposes.

I want to attach my variable data at the end of html page that is sent into the PC to display them in the boxes that are in the middle of the page.

Before that I was forced to find the exact position of variable in the html in the box .

Is there any way to show the data that is attached at the end of the html in the middle boxes of the page?

<!DOCTYPE html>
<html>
<head>
<title>SAAT Co</title>
<h1><center><font color="red"> SAAT Co </font></center></h1>\r\n<h1><fontcolor="blue">   Ethernet Display T24M08 </font></h1>\r\n
<script>
<--
function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
  {
  alert("First name must be filled out");
  return false;
  }
}
-->
</script>
</head>

<body>

   <form name="myForm" action="http://192.168.1.250" onsubmit="return validateForm()" method="post">
<table>
  <tr>
    <td>Firmware Version :</td>
    <td><input type="text" name="dev-info" value=" " ></td>

  </tr>
  <tr>
    <td>MAC Adress :</td>
    <td><input type="text" name="mac-addr"></td>

  </tr>
  <tr>
    <td>IP Adress :</td>
    <td><input type="text" name="ip-addr"></td>

  </tr>
</table>
<input type="submit" value="Apply/Reboot">
</form>
</body>
</html>

If I understand you correctly, you can accomplish what you're trying to do by assigning your values to their appropriate textboxes. The example below does this by giving your textbox an ID and then using javascript to insert your value into that textbox.

      <td>MAC Adress :</td>
      <td><input type="text" id='MacAddy' name="mac-addr"></td>
      ...
      </form>
   </body>
</html>

<script>
    document.getElementById('MacAddy').value = "your_value_here";
</script>

The javascript can be appended to the document in the fashion you described in your post.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM