PDA

View Full Version : How do I use JavaScript to retrieve value of checkbox



moiseszaragoza
13 Aug 2009, 9:01 AM
Hey I am trying to know what is the value of of a check box (true, or false)

but i cant seem to get it write



function getPrice(boxName){

alert(form1.Soft_Top_Cloth.checked) // Hard code box name it works
alert(form1.boxName.checked) // passed threw variable not working
}





<input type="checkbox" name="<%= boxName %>" id="<%= boxName %>>" onchange="getPrice('<%= boxName %>')" />



Thanks for all the help

tryanDLS
13 Aug 2009, 10:44 AM
What does this have to do with Ext? If you don't know how to write Javascript, buy a book or learn to use google.

moiseszaragoza
13 Aug 2009, 11:11 AM
Thanks for being so welcoming

i guess that it does not has anything to do with EXT but it is JS

well in any case

the problem is that there are 2 >'s

it should look like



<input type="checkbox" name="<%= boxName %>" id="<%= boxName %>" onchange="getPrice('<%= boxName %>')" />

tryanDLS
13 Aug 2009, 11:51 AM
That's the point - this is not a forum for general HTML/JavaScript questions with no context.

13 Aug 2009, 12:01 PM
i would use google - specifically w3schools

for instance: http://www.w3schools.com/jsref/jsref_obj_string.asp

moiseszaragoza
13 Aug 2009, 12:17 PM
Thanks for the link it was really helpfull