4 replies [Last post]
gautamz07
gautamz07's picture
Offline
Enthusiast
Last seen: 5 years 41 weeks ago
Timezone: GMT+5.5
Joined: 2014-04-24
Posts: 265
Points: 403

<div class="form-group">
			<label for="gender" class="col-sm-2 control-label">Gender
			</label>
			<div class="col-sm-6<code>
">

Male

Female

The above code is coded using bootstrap 3.0 , though my question has nothing to do with bootstrap , when i put in the "name" attribute it all works fine , basically the code allows me to create radio-buttons and the name attribute allows me to take care of the fact that only one radio-button is checked . now my difficulty is what is so espical in the name attribute that it does the magic of "allowing only one radio-button to be checked" ? (i have a suspicion that there is some javascript or Jquery in the back-end taking care of this in bootstrap , but is this suspicion true . I don't know Sad( ) .

Thank you .

regards .

gautam.

gautamz07
gautamz07's picture
Offline
Enthusiast
Last seen: 5 years 41 weeks ago
Timezone: GMT+5.5
Joined: 2014-04-24
Posts: 265
Points: 403

The actual code

	<div class="form-group">
						<label for="gender" class="col-sm-2 control-label">Gender
						</label>
						<div class="col-sm-6">
 
							<label class="radio-inline">
					<input type="radio" name="genderRadio" value="optional" /> Male
							</label>
 
							<label class="radio-inline">
					<input type="radio" name="genderRadio" value="optiona2" /> Female
							</label>
 
 
						</div>
					</div>	

Reposted the actual code , i donno what happened there .

Thank you.

helldog2004
helldog2004's picture
Offline
Enthusiast
Netherlands
Last seen: 5 years 47 weeks ago
Netherlands
Timezone: GMT+2
Joined: 2014-03-02
Posts: 205
Points: 239

Well you gave them the input

Well you gave them the input type radio, meaning it will create a radio button for this question.
If you are asking a question where there are three different answers possible, and all those answers have an input type of radio then you can only choose one of those three questions.

If you want your visitors to be able to pick multiple answers you might want to use the input type checkbox, instead of radio.

And to answer your question, it does not need any javascripts (yeah some extended forms might use javascript) but not for the radio buttons or checkboxes. (Unless it is being changed by a CSS ofcourse).
But for now, just like the command <html> or <body> (they are known codes being translated by different kind of browsers so they know how to show a page to a visitor) that also happens with the form commands "submit", "checkbox", "radio" and more commands.

Hope this helps you a bit.
Cheers, Henk

Check Maximum Webdesign for your online solutions

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 1 year 17 weeks ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858

Basics

When a form is submitted, the 'name' attribute is the key of the key/value pair sent to the server. It is required on all form controls excepting 'submit' and 'reset'.

The name attribute defines the members of a radio control set, thus:

<input type="radio"
       name="gender">
 
<input type="radio"
       name="gender">

The label element is 'attached' to its form control by the 'for' and 'id' attributes, for example:

<label for="genderm">
  <input type="radio"
         name="gender"
         id="genderm">
male</label>
 
<label for="genderf">
  <input type="radio"
         name="gender"
         id="genderf">
female</label>

Study ยง17.3 The FORM element. Do it again and again. Forms seem to cause confusion, and the only way to clarify things is to learn the rules. It is not to adopt some sort of 'helper' idiocy.

Please, please, please get rid of Bootstrap and any similar 'frameworks'. You are only learning to code stupidly wrong. It is simply easier to learn the correct structure, semantics and syntax.

Why the rant? Look at this: <div class="form-group">. That is stupid, and yells out, "the guy who coded me is gormless". The semantic and structurally correct element is <fieldset>.

And now back to our regularly scheduled programming,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

gautamz07
gautamz07's picture
Offline
Enthusiast
Last seen: 5 years 41 weeks ago
Timezone: GMT+5.5
Joined: 2014-04-24
Posts: 265
Points: 403

Thank you gary .

Hey gary ,

I really appreciate your advice , thing is i am a grad out of collage in a job , in a very small company and my boss is like "YOU NEED TO RUN BEFORE U LEARN TO WALK " , not that he's wrong , but the way i like to learn is the chinesses way , I.E. "FOR A STRUCTURE TO STAND THE FOUNDATION MUST BE GOOD" . but in a quest to complete my task i need to use bootstrap , that does not mean i love it or am not focussed on CSS . infact , everytime i find a new CSS element , i go research on it and find out how it works . I use bootstrap jst as a tool, to complete my work, But my focus is on Core css , i world love to see the day when i build a website from ground up (that day would be far away) and I'd surely review it with u too Smile :) Smile Wink

and yeah i have heard that property call feildset too , used it a bit here and there . I am learning gary pls don't be so harsh on me Tongue .

And Thank you though , i know u mean good when u say , Frameworks are not good for "beginners" . Oh ! and i envy the Five stars you have , i have only one yet Sad is there anyway i can change that using CSS gary ? lol Joke.

Kind regards .

Gautam.