How do I hide the submit button using javascript? Reason is because my form checkboxes submits the form on click but only when JS is enabled. For those with JS disabled, I want them to see the submit button, so I want to hide the submit button using JS. I'm using Codeigniter if this helps. Thanks!
How do I hide the submit button using javascript? Reason is because my form checkboxes submits the form on click but only when JS is enabled. For those with JS disabled, I want them to see the submit button, so I want to hide the submit button using JS. I'm using Codeigniter if this helps. Thanks!
Share Improve this question asked May 19, 2011 at 5:13 NyxynyxNyxynyx 63.7k163 gold badges506 silver badges855 bronze badges 1-
2
Then use script to hide the button with
submitButtonRef.style.visibility = 'hidden';
, after the button is in the DOM of course (use the load event or similar). – RobG Commented May 19, 2011 at 5:20
4 Answers
Reset to default 7Why javascript when noscript will do the job:
<form>
.
.
.
<noscript>
<input type="submit" />
</noscript>
</form>
simple javascript,
<body onload="hideButton()">
<script>
function hideButton()
{
document.getElementById("buttonId").style.display='none';
//or you can try
//document.getElementById("buttonId").style.visibility='hidden';
}
</script>
<input type="submit" value="submit" id="buttonId" />
</body>
It is very easy to hide a submit button:
<form method="post/get" action="#">
<input type="Text" name="xyz">
<input type="submit" style="visibility:hidden">
</form>
In jQuery:
$(document).ready(function() {
$('#buttonId').hide();
});