• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

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!
0
MayoorPatel
Asked:
MayoorPatel
  • 2
1 Solution
 
Michel PlungjanIT ExpertCommented:
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="">
0
 
Michel PlungjanIT ExpertCommented:
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
0
 
MayoorPatelAuthor Commented:
Brilliant thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now