function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sadik Shaik 3Sadik Shaik 3 

When i click on a command link popup window should open on the same page and that should get submitted when onload but i am getting the error "TypeError: document.getElementById(...) is null"

Beloe is my code:
<script type="text/javascript">
    function showBox(no) {
        var noval= document.getElementById(orderno).innerHTML;
        var box = new parent.SimpleDialog("helder"+Math.random(), true);
        parent.box = box;
        box.setTitle("Details");
        box.createDialog();
        box.setWidth(1300);
        box.setContentInnerHTML("<form method = \"POST\"action=\"https://google.com/\" target=\"orderdetil\"><input type=\"hidden\" name =\"TARGET\" value=\"https://www.w3schools.com/\" /><input type=\"submit\" id=\"clickevent\" value=\"submit\"/></form><input type=\"button\" style=\"background-color:#E01E0F;margin-top: 1px;margin-right: 2px;position:absolute;top:0;right:0;\" value=\"X\" onclick=\"box.hide();\"/><iframe name=\"orderdetail\" src=\"https://www.w3schools.com/\" height=\"500\" width=\"1280\" frameborder=\"0\" style=\"border:none; margin-left:0; margin-right: auto; height:600px;z-index:1;\"></iframe>");
        box.setupDefaultButtons();
        box.show();
            console.log('inside Click Box onload:::');
            document.getElementById("clickevent").click();
            console.log('hi:::');
            document.getElementById("clickevent").style.display = 'none';  
    }
    </script>
Wheni use the id of input in "document.getElementById("clickevent").click();"  when i open the popup window  i am getting below error "TypeError: document.getElementById(...) is null",
Please anyone help me on this.
Quick response is very helpfull for me. .
Advance in Thanks,
Sadik
@Amit Kumar Giri@Amit Kumar Giri
"clickevent" is not an direct field id like input text/outputtext , etc for example in ur JS so you can not access the event before it has loaded. 
After your showBox function, before scripts end do this and try.
window.onload = function () {
   document.getElementById("clickevent").click();
   document.getElementById("clickevent").style.display = 'none';
};
** If you would have an id field in ur JS then ur code would have worked fine like below. Lets say "clickevent" is the id of a checkbox. Then Your code similar to below will work.
<html>
	<body>	
	<form>
	  <input type="checkbox" id="clickevent" onmouseover="callthisFunction()" onclick="alert('click here')">
	</form>
	<script>
	function callthisFunction() {
		document.getElementById("clickevent").click();
	}
	</script>
	</body>
</html>


 
Sadik Shaik 3Sadik Shaik 3
Hi Amit kumar,
After showbox function only i have tried this but i am getting "document.getelementby is null".
The id i am using from box.setContentInnerHTML in inupt tag.
please help me on this.

Thanks,
sadik