SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting values from checkboxes in another frame

    Howdy folks,

    This one has been driving us nuts. We're working with two frames. The top one has two buttons. The bottom one has a bunch of check boxes that are all in the same group but have different values. When we press either of the buttons, it's supposed to shoot us to a php page that we made.

    So we're using javascript on the buttons in the top frame to post the form in the bottom frame. However, due to some error handling, we've got to get a value or the length or anything that will give us information that show us if any boxes have been checked when we press either of the buttons in the top frame.

    This code doesn't work. Can anyone suggest any changes?

    Code:
    //gen_bottom is the frame name where the form is located
    
    <SCRIPT language="JavaScript">
    function submitform()
    {
    	if(top.frames.gen_bottom.ClickDragForm.check.value > 0)
    	{
    	    alert("Checked");
    	    top.frames.gen_bottom.ClickDragForm.submit();
    	}
    	else
    	{
    	    alert("not Checked");
    	}
    }
    function submitform2()
    {
      top.frames.gen_bottom.ClickDragForm.button_select.value = "addwork";
      top.frames.gen_bottom.ClickDragForm.submit();
    }
    </script>

  2. #2
    SitePoint Enthusiast Gridlight's Avatar
    Join Date
    Apr 2005
    Location
    Oxford, UK
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can't you loop through the checkboxes and look for a .checked?

    For example:

    Code:
    var theBoxes = top.frames.gen_bottom.document.getElemtentsByTagName('checkbox');
    for (i=0; i<=theBoxes.length; i++)
    {
       if (theboxes[i].checked)
       {
           alert('Checked box found');
           break;
       }
    }
    (Untested)
    Cheers,
    Gridlight

    BrowserCam for 30?! I'm in, are you?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •