Dynadot โ€” .com Transfer

Simple Javascript question

SpaceshipSpaceship
Watch
Impact
111
Hi all,

Quick JS question: how can I get a submit button to be DISABLED as the <body> loads, then ENABLE it when a function in a script.js file is called by another event?

I have something sort of laid out, but it just doesn't work... can anyone offer me an example? Internet searches have yielded little help :(

Thanks!
-Matt
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
I think following code will help

-----------------------------------------------------
<HTML>
<HEAD>

<script type="text/javascript">
<!--

function ChangeStatus(val) {
frm=document.forms[0]
if(val=="enable")
{frm.Button1.disabled=false}
if(val=="disable")
{frm.Button1.disabled=true}
}
// -->
</script>


</HEAD>
<BODY TEXT="000000" BGCOLOR="FFFFFF">

<form>
<div align="center">
<select name="select" onChange="ChangeStatus(this.value)">
<option value="disable">Disable Button 1</option>
<option value="enable">Enable Button 1</option>
</select>
</div>
<p align="center">
<input type=button onClick="alert('Button 1 pressed!')" value="Button 1" name="Button1">

<script type="text/javascript">
<!--
ChangeStatus("disable");
// -->
</script>
</form>
</BODY>
</HTML>
--------------------------------------------

Here how it works, first you define a function with the javascript that enables and disables a button, which I named as ChangeStatus, later in the html part after your form part there comes a smal javascript code which calls ChangeStatus and says disable this button, this allows you to start page with a disabled button.

And the dropdown usage, calls ChangeStatus with enable and disable values to activate and disactivate the button. Instead of a dropdown, simply you can integrate it to another event, depends on your usage.

Hope it helps :)
 
Last edited:
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back