Capturing the value of form elements on submit within an Iframe

Posted on 2007-07-26
Last Modified: 2012-05-05
Hi there I have a form with various form elements on it, textboxes, e.t.c I also have 4 iframes which hold form elements. At the moment when I submit the form the values of the iframes are not being submitted, only the values on the parent form are being submitted. Is there anyway I can capture the values of the iframes as well as the parent form values?

Here is an example of the Iframe.

                src = 'clientdrp.asp'  
                id = 'ifrClient'
                name = 'ifrClient'      
                frameborder = '0'
                width = '230'
                height = '20'

and here is an example of the content within that Iframe.

<div id="menu" style="position: absolute; top: 0px; width: 436px; left: 0px;" align=left>
   <select name="ContactID" size="1">
    <option value="0">-- Please Select A Contact--</option>                        
    Do Until objRSProjectManagerList.EOF
        Response.Write("<option value=""" & objRSProjectManagerList.Fields("Id") & """>" & objRSProjectManagerList.Fields("FirstName") & " " & objRSProjectManagerList.Fields("LastName") & "</option>")
    Set objRSProjectManagerList = Nothing

as you can see the name of that dropdown is ContactID, so if I could capture that, it woujld be great.

Thanks in Advance!
Question by:MayoorPatel
    LVL 75

    Expert Comment

    by:Michel Plungjan
    From the same server?

    function getContact() {
      if (window.frames.length==0) return ""; // no iframes here
      var ifr = window.frames['ifrClient'];
      if (!ifr) return ""; // no iframe called ifrClient here
      var sel = ifr.document.forms[0].ContactID;
      return sel.options[sel.selectedIndex].value
    <form onSubmit="this.hiddenContactID.value=getContact()">
    <input type="hidden"name="hiddenContactID" value="">
    LVL 75

    Accepted Solution

    Assuming the contact select is wrapped in a <form> tag by the way
    otherwise it would be
    var sel = ifr.document.getElementsByName('ContactID')[0]
    return sel.options[sel.selectedIndex].value
    LVL 1

    Author Comment

    Brilliant thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now