HTML DOM इनपुट रेडियो टाइप प्रॉपर्टी उस इनपुट एलिमेंट से जुड़ी है जिसका टाइप ="रेडियो" है। यह इनपुट रेडियो तत्व के लिए हमेशा रेडियो लौटाएगा।
सिंटैक्स
रेडियो प्रकार की संपत्ति के लिए वाक्य रचना निम्नलिखित है -
radioObject.type
उदाहरण
आइए रेडियो प्रकार की संपत्ति के लिए एक उदाहरण देखें -
<!DOCTYPE html>
<html>
<body>
<h1>Input radio type Property</h1>
<form>
FRUIT:
<input type="radio" name="fruits" id="Mango">Mango
<br>
</form>
<p>Get the above input element type by clicking the below button</p>
<button type="button" onclick="radioType()">GET Type</button>
<p id="Sample"></p>
<script>
function radioType() {
var P=document.getElementById("Mango").type;
document.getElementById("Sample").innerHTML = "The type for the input field is: "+P ;
}
</script>
</body>
</html> आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा -

GET टाइप बटन पर क्लिक करने पर -

हमने पहले टाइप ="रेडियो", नाम ="फल", आईडी ="आम" के साथ एक फॉर्म के अंदर एक इनपुट तत्व बनाया है -
<form> FRUIT: <input type="radio" name="fruits" id="Mango">Mango </form>
फिर हमने एक "GET प्रकार" बटन बनाया जो उपयोगकर्ता द्वारा क्लिक किए जाने पर रेडियोटाइप () विधि को निष्पादित करेगा -
<button type=”button” onclick="radioType()">GET Type</button>
रेडियोटाइप () विधि getElementById () विधि का उपयोग करके इनपुट तत्व प्राप्त करती है और इसके प्रकार विशेषता मान को चर P को निर्दिष्ट करती है। इस चर को इसके आंतरिक HTML संपत्ति का उपयोग करके "नमूना" आईडी के साथ पैराग्राफ में प्रदर्शित किया जाता है -
function getType() {
var P = document.getElementById("Mango").type;
document.getElementById("Sample").innerHTML = "The type for the input field is : "+P;
}