Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorjay0316
    • CommentTimeMay 30th 2008
     permalink
    I have an image uploader java applet that uses javascript to submit form data along with images. The problem is that it doesn't handle radio buttons properly. No matter which radio button is selected, it will always take the last value. The place where I got the applet isn't giving much interms of support, and there aren't many options when it comes to uploading multiple images along with form data. So, I'm hoping that someone would be able to look at the function they are using to collect the form data and give me some insight into how to modify it to get the checked value from the radio button.

    Thanks!

    Here is the code:
    function r_getFormData()
    {
    if(document.forms[0] == undefined)
    {
    return;
    }
    for(i = 0 ; i < document.forms[0].elements.length ; i++)
    {
    document.rup.jsAddTextField(document.forms[0].elements[i].name,
    document.forms[0].elements[i].value);
    }
    }
    • CommentAuthorsoulID
    • CommentTimeJun 2nd 2008
     permalink
    Did you figure this out yet? If you have a link to a test page, that might make it clearer as to what you're trying to do. But as far as the above code goes, in the for-loop, you end up looping through all of "i" - so every time you hit the last line in the for-loop, the value is different. If you're using that value and storing it somewhere, then the variable storing that value will always be the last value of what "i" is.

    If you're trying to get just the checked items, then in the function, check whether a form element is checked. It will return a boolean (e.g. using the .checked method).
Add your comments
    Username Password
  • Format comments as (Help)