oh, I misunderstood what you meant the first time. .val() instead of check should work....
originally I had wanted to collect all the values into one variable for the checkboxes, but I ran into some problems so I changed over to making a field for each checkbox. On Feb 20, 9:29 pm, Hamish Campbell <[EMAIL PROTECTED]> wrote: > What version of jQuery are you using? .val() should return "" rather > than undefined if you find inputs successfully. > > HOWEVER, there is another problem: > > Putting ':checked' means that if the boxes are NOT checked, jQuery > won't find them so .val() doesn't exist for the object. Remove the > ':checked' and try again. > > Cheers, > > Hamish > > On Feb 21, 11:32 am, Robert Hill <[EMAIL PROTECTED]> wrote: > > > Hello > > > I'm collecting a number of values from various form elements: > > textfield, radio, checkbox. > > > since some of the fields aren't require on my form, when I POST their > > values they are returned as 'undefined' > > > is there a way in Jquery that would allow me to set all variables that > > are undefined with a given value like "N/A" or even just ""? > > > for example, after the form is submitted, I'm using the following code > > to populate my values: > > //cancer vars > > var cancerVal = $("input[name='cancer']:checked").val(); > > var cancerTypeVal = $("#cancerType").val(); > > var cancerDateVal = $("#cancerDate").val(); > > var chemoCanVal = $("input[name='chemoCan']:checked").val(); > > var radiationCanVal = > > $("input[name='radiationCan']:checked").val(); > > var surgeryCanVal = > > $("input[name='surgeryCan']:checked").val(); > > var otherCanMoreVal = > > $("input[name='otherCanMore']:checked").val(); > > > doing something like: > > > var chemoCanVal =""; > > > before the submit does not seem to help. > > > Alternately, if there is a way that I can use a function to replace > > all instances of 'undefined' with another value after the form is > > submitted, that too would work. > > > thanks in advance! > > > cheers, > > -robert