Home  >  Article  >  Web Front-end  >  Add client script for radio type INPUT (Additional implementation JS to disable onClick event idea code)_Form special effects

Add client script for radio type INPUT (Additional implementation JS to disable onClick event idea code)_Form special effects

WBOY
WBOYOriginal
2016-05-16 18:16:351616browse

The following example will show the result of displaying a commit without overloading.
When the user selects an option above, a function called "getVote()" is executed. The "OnClick" event triggered by this function

Copy code The code is as follows:

< html>






Do you like PHP and AJAX so far?



Yes:


No:







The getVote() function does the following:
Create an XMLHttpRequest object
Create the function to be executed when the server response is ready
Send the request off to a file on the server
Notice that a parameter (vote) is added to the URL (with the value of the yes or no option)
Determine whether the disabled attribute of the control is true, if so return false; implement the onclick event of disabling the radio and can Enable it again
Method 1: (To achieve disabling and re-enabling functions at the same time, it can only be used for button text type INPUT, and its onclick event cannot be disabled for divs)






Method 2, 3 : (To remove the onclick event of the radio, you need to re-register the event again. You can disable the onclick event of the div)




Three:
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn