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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...