Sometimes we do not want the user to submit data repeatedly, so we want the user to submit the form after the button is temporarily unavailable, and the data cannot be submitted again. Next we will introduce two instances.
Instance 1
The Code is as follows: |
Copy code |
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <Html xmlns = "http://www.w3.org/1999/xhtml"> <Head> <Title> the button is dimmed after the JS form is submitted </title> <Meta http-equiv = "content-type" content = "text/html; charset = gb2312"> </Head> <Body> <! -- Add the following code to the <body> and </body> --> <Form name = "form1" method = "post" action = "http://www.bKjia. c0m"> <Input type = "text" name = "username" value = "zzsky"> <Input type = "button" value = "" onclick = "<a href = http://www.bKjia. c0m target = _ blank> javascript </a>: {this. disabled = true; document. form1.submit ();} "> </Form> </Body> </Html> |
Instance 2
The Code is as follows: |
Copy code |
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <Html xmlns = "http://www.w3.org/1999/xhtml"> <Head> <Title> dimmed code after the form is submitted </title> <Meta http-equiv = "content-type" content = "text/html; charset = gb2312"> </Head> <Body> <Script language = "javascript"> Function my_submit (){ Document. form1.submit (); Document. form1.submit1. disabled = true; } </Script> <Form action = "/" method = "post" name = "form1"> <Input type = "text" name = "name"> <Input type = "button" name = "submit1" value = "Submit" onClick = "javascript: my_submit ();"> </Form> </Body> </Html> |