आज इस आर्टिकल में हम आपको HTML Form Element Tutorials in Hindi – Part 18 के बारे में बताएँगे.
HTML Form Element वो element है जो हम form element में इस्तेमाल करते है जैसे हमने आपको पिछले आर्टिकल में <input>
element के बारे में बताया था.
HTML <input>
Element
इस element का इस्तेमाल user से input के लिए इस्तेमाल करते है. इस element में type attribute का इस्तेमाल किया जाता और इसके अलग अलग type हमने आपको पिछले आर्टिकल में बताये थे. Input Type Attribute Value>>>>>
<input type="text">
HTML <Select>
Element
इस element का इस्तेमाल dropdown लिस्ट बनाने के लिए किया जाता है. इस element में हम <option>
element के द्वारा list item तैयार कर सकते है जैसा की आपको नीचे example में दिखाया गया है.
<select name="list">
<option value="item1" selected>item1</option>
<option value="item2">item2</option>
<option value="item3">item3</option>
<option value="item4">item4</option>
</select>
इसमें हमने name attribute का इस्तेमाल किया है जिसके द्वारा हम server side script में इसको एक्सेस कर सकते है. <option>
में हमने value attribute का इस्तेमाल किया है जिसमे एक value हमने हर अलग आप्शन को दी है ताकि जब भी user form को submit करे तो इसमें से selected value आपको server side script में आसानी से एक्सेस हो जाए.
हम <option>
element में selected attribute का इस्तेमाल भी करते है जिससे आपका एक आप्शन automatic select रहता है चाहे user कोई आप्शन ना सेलेक्ट करे.
इसके अलावा अगर हम चाहे तो user से multiple आप्शन भी सेलेक्ट करवा सकते है इसके लिए आपको select element में multiple attribute का इस्तेमाल करके कई option सेलेक्ट कर सकते है.
अगर आप कई आप्शन dropdown menu में show करवाना चाहते है तो आप size attribute का इस्तेमाल करके इसमें number value डाल सकते है.
HTML <textarea>
Element
इसका इस्तेमाल user से multi-line text input ले सकते है.
<textarea name="yourmsg" rows="10" cols="30">
you are awesome!
</textarea>
इसमें हमने cols और rows attribute का इस्तेमाल किया है जो textarea की width और height को define करने के लिए किया जाता है.
इस element का इस्तेमाल करके आप अपने डॉक्यूमेंट में button को add कर सकते है.
<button type="button" onclick="alert('Hello World!')">Click Me!</button>