javascript - Getting selected Radiobutton values into the Struts2 Action class -


I get the answer to the question and the javascript selected answer from the radio button and storing those values ​​in those two values These two arrays need to be stored in the Straits 2 action class and in store.

Javascript code:
  & lt; script type = "text / javascript" & gt; Var nomrat = []; Var i = 0; Var calculation = []; Function Handler (_this) {var qno_name = _this.name; Var id = qno_name.substring (1); Var qid = $ ("# id" + id) .val (); // warning ("qid" + qid) var ans = _this.value; nameArry [i] = ans; // warning (ans); // warning (idle [i]); Count [i] = qid; I = I + 1; / * Document.write (nameArry); Warning (nameArry); * / /} & Lt; / Script & gt;   

JSP code:
  & lt; Table id = "neologist" class = "table-table-stripe table-barbed table-hover" & gt; & Lt; TR & gt; & Lt; Th & gt; SL.No. & lt; / Th & gt; & Lt; Th & gt; Question & lt; / Th & gt; & Lt; Th & gt; QID & lt; / Th & gt; & Lt; Th & gt; Very small like me & lt; / Th & gt; & Lt; Th & gt; Like A Little & lt; / Th & gt; & Lt; Th & gt; I like & lt; / Th & gt; & Lt; Th & gt; Like a Lot, I & lt; / Th & gt; & Lt; / TR & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt;% int i = 0; & Gt%; & Lt; S: form action = "learningmodity rational action" & gt; & Lt; S: Iterator value = "lModlity" state = "var" var = "true" id = "im" & gt; & Lt;% i ++;% & gt; & Lt; Td> & Lt; S: attribute value = "# var.index + 1" /> gt; & Lt; / Td> & Lt; Td> & Lt; S: Property value = "modalityquestName" /> gt; & Lt; / Td> & Lt; Td> & Lt; S: Property value = "moadlityquestionId" /> gt; & Lt; / Td> & Lt ;! - & lt; Td square = "hides -480" & gt; & Lt; Select name = "R & lt;% = i%"; Contenteditable = "2" id = "MySelectOption" onchange = "Handler ();" & Gt; & Lt; Option value = "1" selected & gt; 1 & lt; / Options & gt; & Lt; Option value = "2" & gt; 2 & lt; / Options & gt; & Lt; Option value = "3" & gt; 3 & lt; / Options & gt; & Lt; Option value = "4" & gt; 4 & lt; / Options & gt; & Lt; / Select & gt; - & gt; & Lt; Span class = "lbl" & gt; & Lt; / Span & gt; & Lt; S: hidden name = "module queryname" value = "% {modalityquestName}" id = "id% {# var.index + 1}" /> & Lt; td square = "hides -480" & gt; & Lt; Input name = "R & lt;% = i%"; Value = "1" type = "radio" onclick = "handler (this)" /> & Lt; Span class = "lbl" & gt; & Lt; / Span & gt; & Lt; / Labels & gt; & Lt; / TD & gt; & Lt; td square = "hides -480" & gt; & Lt; Input name = "R & lt;% = i%"; Value = "2" type = "radio" onclick = "handler (this)" /> & Lt; Span class = "lbl" & gt; & Lt; / Span & gt; & Lt; / Labels & gt; & Lt; / TD & gt; & Lt; Td square = "hides -480" & gt; & Lt; Input name = "R & lt;% = i%"; Value = "3" type = "radio" onclick = "handler (this)" /> & Lt; Span class = "lbl" & gt; & Lt; / Span & gt; & Lt; / Labels & gt; & Lt; / TD & gt; & Lt; Td square = "hides -480" & gt; & Lt; Input name = "R & lt;% = i%"; Value = "4" type = "radio" onclick = "handler (this)" /> & Lt; Span class = "lbl" & gt; & Lt; / Span & gt; & Lt; / Labels & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / TR & gt; & Lt; / TR & gt; & Lt; / s: iterator & gt; & Lt; Div class = "form-action" & gt; & Lt ;! - & lt; Button class = "BTN BTN-Success" & gt; Save & lt; / Button & gt; - & gt; & Lt; S: Submit Value = "Save" Action = "LearningModelity Result Action" & gt; & Lt; / S: Submit & gt; & Lt; Button class = "btn" type = "reset" & gt; & Lt; i class = "sign-undo larger -110" & gt; & Lt; / I & gt; Reset & lt; / Button & gt; & Lt; Button class = "BTN BTN-notification" type = "button" & gt; & Lt; I class = "" & gt; & Lt; / I & gt; Cancel & lt; / Button & gt; & Lt; / Div & gt; & Lt; / S: Forms & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;    

I tried the same thing with the checkbox, I hope this radio The button will also work.

First of all, you need to create an example HTTPSvette request for the action class with the gates and the setters. Now you see the page (jsp or html) giving a name to your radiobutton. , Like my radio boots.

Now in action class, string [] checkbox = request.getParameterValues ​​("myRadioButtons");

Now upwards you can get arrays of values ​​with 1s and 0s.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -