Dashboards & Visualizations

Why am I unable to insert this HTML into my dashboard?

tmontney
Builder

In Splunk Web, it says "unexpected close tag". I ran this through https://validator.w3.org/ and it passed as HTML 4.01 Transitional.

<html>
        <head>
<title>"Hello"</title>
<meta charset="utf-8"/>
</head>
        <script type="text/javascript">
          function httpPost(theUrl)
{
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4)
        {
        if (xmlhttp.status==200)
        {
            writetobody(xmlhttp.responseText);
            }
        }
    }
    var unameVal = document.getElementById("uname").value;
    var newUrl = theUrl.replace("REPLACEME", unameVal);
    xmlhttp.open("GET", newUrl, true );
    xmlhttp.send(); 
}
        </script>

        <script type="text/javascript">
            function writetobody(data) {
            if (data!=null) {
            var json = JSON.parse(data);
            for (i = 0; json.length > i; i++) {
            var v1 = json[i]["v1"];
            var v2 = json[i]["v2"];
                        document.getElementById('main').innerText=("\r\nval1: " + v1 + "\r\nval2" + v2);
            }

            }
            }
    </script>
<script type="text/javascript">
    window.onload = function () { 

    }
</script>
         <div id="frm" style="width:  300px; height: 100px; float: left;">
           Usernames (separate by comma): <input type="text" id="uname">;
           <input id="unameSubmit" type="button" value="Submit" onclick="httpPost('http://www.mysite.com');">
         **</div>**

       <div id="main" style="width: 400px; height: 300px; float:left;"></div>
           </html>

The div tag "in bold", near the bottom, is the line in question. I have also been unable to use "body" or "form" tags.

0 Karma
1 Solution

lquinn
Contributor

Try closing your input tags, just above the div in question. So the div would become:

<div id="frm" style="width:  300px; height: 100px; float: left;">
        Usernames (separate by comma): <input type="text" id="uname"/>;
        <input id="unameSubmit" type="button" value="Submit" onclick="httpPost('http://www.mysite.com');"/>
 </div>

View solution in original post

lquinn
Contributor

Try closing your input tags, just above the div in question. So the div would become:

<div id="frm" style="width:  300px; height: 100px; float: left;">
        Usernames (separate by comma): <input type="text" id="uname"/>;
        <input id="unameSubmit" type="button" value="Submit" onclick="httpPost('http://www.mysite.com');"/>
 </div>

tmontney
Builder

Huh, the one area I didn't think to check. It doesn't like the "input" tags. Remove them, and it's happy.

0 Karma

lquinn
Contributor

It came up as an error for your div tag because it was expecting your input tags to be closed first. Sometimes you can get away with not closing the input tags but I guess you can't in this instance.

0 Karma

tmontney
Builder

It also didn't like my br tag. I left it out as Splunk Answers kept translating it.

0 Karma
Get Updates on the Splunk Community!

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...