java - How to make a radio button deselected by default in Struts2 -


Can someone tell me how to set the default value of the radio button empty and then get the value from the customer who Update the table accordingly the user chooses.

I am using the following code snippet, but there is something wrong:

  var blnValue4 = false; (Var i = 0; i & lt; document.forms [0] .chkTeam.length; i ++) {if (document.forms [0] .chkTeam [i]. Probe) blnValue4 = document.forms [ 0] .chkTeam [I do it; Return blnValue4; } If (blnValue4 = false) {Warning ("Please answer the question in team participation."); Document.getElementById ("chkTeam") focus () .; return false; }   

And then how do I assign a default value:

  & lt; Td colspan = 2 & gt; : & Lt; Html: radio property = "chkTeam" value = "" /> Yes & lt; Html: radio property = "chkTeam" value = "" /> No & lt; / Td>   

Note that in the form it is set to accept Boolean as return type.

Please do not understand your question, can not be deselected or deselected. As the unselected mean value is not selected, unselected means special person or part should be disqualified. The following codes are normal, like the ignial and the list, as they are the following:

But, create a radio button through OGNL expression and select "??? 2" as the default value.

  & lt; S: radio label = "answer" name = "your answer" list = "# {'1': 'yes', '2': 'no'}" value = "2" />   

This will generate the following HTML code. |

  & lt; Input type = "radio" name = "yourAnswer" id = "resultAction_yourAnswer1" value = "1" /> & Lt; Label = "resultAction_yourAnswer1" & gt; Yes & lt; / Label & gt; & Lt; Input type = "radio" name = "your answer" id = "resultAction_yourAnswer2" check = "check" value = "2" /> & Lt; Label = "resultAction_yourAnswer2" & gt; No & lt; / Label & gt;   

In Java code, create a list to return values ​​for the radio button.

  list & lt; String & gt; Gender = new Arasuichi & lt; String & gt; (); Genders.add ("male"); Genders.add ("female"); Genders.add ("unknown"); Public listing & lt; String & gt; Meldguider () {Return gender; } Public string getDefaultGenderValue () {return "unknown"; }   

In the results page, tag, list = â ???? Genders To return the list of keys and values ​​for the radio button will call the getGenders () method and value = one ??? Default gender value ???? The value of the default button for the radio button will call the getDefaultGenderValue () method to choose a 'weird' unknown.

  & lt; S: radio label = "gender" name = "your gender" list = "gender" value = "default gender" />   

Will this generate the following HTML code? |

  & lt; Input type = "radio" name = "your gender" id = "resultAction_yourGendermale" value = "male" /> & Lt; Label = "resultAction_yourGendermale"> gt; Men & lt; / Label & gt; & Lt; Input type = "radio" name = "yourGender" id = "resultAction_yourGenderfemale" value = "female" /> & Lt; Label = "resultAction_yourGenderfemale" for => Female & lt; / Label & gt; & Lt; Input type = "radio" name = "yourGender" id = "resultAction_yourGender unknown" check = "check" value = "unknown" /> & Lt; Label = "resultAction_yourGender unknown" for = & gt; Unknown & lt; / Label & gt;    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -