total amount is getting displayed as NAN,javascript -


I have a form in which I have two sets of radio buttons and a text box to record the value of the quantity . Depending on the radio button, the value in the selected and quantity text box should be populated with the total textbox values. I am using the array to calculate, but in the total areas the value is displayed in the form of NAN Is anyone can see my code and tell me where I am wrong?

  ** HTML ** & lt; Form id = "orderform" name = "orderform" & gt; & Lt; Fieldset data-role = "control group" & gt; & Lt; Story & gt; & Lt; P & gt; Options & lt; / P & gt; & Lt; / Narrative & gt; & Lt; Input type = "radio" name = "likes" id = "veg" value = "1" checked onclick = "total ()"> & Lt; Label = "veg" & gt; Vegetarian & lt; / Labels & gt; & Lt; Input type = "radio" name = "likes" id = "nonveg" value = "2" onclick = "total ()"> & Lt; Label = "nonveg" & gt; Meat lover & lt; / Label & gt; & Lt; / Fieldset & gt; & Lt; Fieldset data-role = "control group" & gt; & Lt; Story & gt; & Lt; P & gt; Size & lt; / P & gt; & Lt; / Narrative & gt; & Lt; Input type = "radio" name = "size" id = "small" onclick = "total ()" & gt; & Lt; Label = "small" & gt; Small & lt; / Label & gt; & Lt; Input type = "radio" name = "size" id = "medium" onclick = "total ()" & gt; & Lt; Label = "medium" & gt; Medium & lt; / Label & gt; & Lt; Input type = "radio" name = "size" id = "big" onclick = "total ()" & gt; & Lt; Label = "big" & gt; Big & lt; / Label & gt; & Lt; Span class = "validation" & gt; & Lt; / Span & gt; & Lt; / Fieldset & gt; & Lt; Div & gt; & Lt; P & gt; Quantity & lt; / P & gt; & Lt; Input type = "text" id = "qty" name = "qty" size = "5" onclick = "total ()" & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; P & gt; Total & lt; / P & gt; & Lt; Input type = "text" id = "amt" name = "AMT" readonly = "readonly" & gt; & Lt; / Div & gt;  JavaScript   9.99,10.99,11.99]]; Function total () {var row = document.query selector ('input [name = "choice"]: checked'). Value; Var column = document.query selector ('input [name = "size"]: checked'). Values; Var quantity = document. GetElementById ("Quantity"). Values; Var Total = 0; Total = (Array [row] [Column] +1) * Quantity; Document.orderform.amt.value = Total; }  

After

you must change the size group in html like the following

  & lt; Legend & gt; & Lt; B & gt; Size & lt; / B & gt; & Lt; / Legend & gt; & Lt; Input type = "radio" name = "size" id = "small" value = "1" onclick = "total ()"> & Lt; Label = "small" & gt; Small & lt; / Label & gt; & Lt; Input type = "radio" name = "size" id = "medium" value = "2" onclic = "total ()" & gt; & Lt; Label = "medium" & gt; Medium & lt; / Label & gt; & Lt; Input type = "radio" name = "size" id = "big" value = "3" onclick = "total ()"> & Lt; Label = "big" & gt; Big & lt; / Label & gt; & Lt; Span class = "validation" & gt; & Lt; / Span & gt;  

This will work for you


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -