Link to home
Start Free TrialLog in
Avatar of MayoorPatel
MayoorPatel

asked on

Capturing the value of form elements on submit within an Iframe

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.

<iframe  
                src = 'clientdrp.asp'  
                id = 'ifrClient'
                name = 'ifrClient'      
                frameborder = '0'
                width = '230'
                height = '20'
                marginwidth="0"
                marginheight="0"
                hspace="0"
                vspace="0"
                border="0"            
                scrolling="no">
                </iframe>

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>")
        objRSProjectManagerList.MoveNext
    Loop
    Set objRSProjectManagerList = Nothing
    %>
    </select>
</div>

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

Thanks in Advance!
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

From the same server?


<script>
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
 
}
</script>
<form onSubmit="this.hiddenContactID.value=getContact()">
<input type="hidden"name="hiddenContactID" value="">
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MayoorPatel
MayoorPatel

ASKER

Brilliant thanks!