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!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...