StefanRSA Posted March 11, 2013 Share Posted March 11, 2013 I have a form in an iframe in a parent form. The iframe has a multiple select box.... I am trying to transfer the Iframe fields to the parent form on parent form submit. All works fine for text fields, but the multiple select field do not $_Post the multiple selected values, and only the first selected option in the form.... What am I doing wrong? function fillValues(form){ var iElements=document.getElementById('iframe_id').contentWindow.document.forms['iframe_name'].elements, e, i=0; while(e=iElements[i++]){ form[e.name].value=e.value; } } This only transfer the first selected option in the multiple option field. Any help? The Parent Form: <head> <script type="text/javascript"> function fillValues(form){ var iElements=document.getElementById('iframe_id').contentWindow.document.forms['iframe_name'].elements, e, i=0; while(e=iElements[i++]){ form[e.name].value=e.value; } } </script> </head> <body> <? print "<pre>"; print_r($_POST); print "</pre>"; if($_POST){ $workStyle = $_POST['multiselect']; var_dump($workStyle); // Setting up a blank variable to be used in the coming loop. $allStyles = ""; // For every checkbox value sent to the form. foreach ($workStyle as $style) { // Append the string with the current array element, and then add a comma and a space at the end. $allStyles .= $style . ", "; } $allStyles = substr($allStyles, 0, -2); echo '<br>The List: '.$allStyles; } ?> <form action="<?=$root?>/member/bl_select_f.php" method="post" onsubmit="return fillValues(this)"> <input type="text" name="MainFfield" value="MainForm"> <input type="hidden" name="banner1" value=""> <input type="hidden" name="banner_name_2" value=""> <input type="hidden" name="multiselect[]" value=""> <iframe name="theselect" id="iframe_id" src="<?=$root?>/member/test1.php" height="550" width="943"> </iframe> <center>TEST<br> <input type="submit" name="blistin" id="blistin" value="Submit"> <br> TEST</center> </form> </body> The Iframe: <form name='iframe_name' id='iframe_id' method='post' action=''> <input type="text" name="banner1" value="IFRAME BOOM 1"> <input type="text" name="banner_name_2" value="IFRAME BOOM 2"> <select id="multiselect_groups" name="multiselect[]" class="multiselect" multiple="multiple"> <option value="Yes">Yes</option> <option value="No">No</option> <option value="Maybe">Maybe</option> </select> </form> Link to comment https://forums.phpfreaks.com/topic/275506-transfer-multiple-select-field-in-iframe-to-parent-on-parent-submit/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.