samedi 28 février 2015

Unable to Pass Values from One PHP Page to Another


There is similar code in the application that works in this same fashion, but my addition is not working. I can get the search page to pop-up in a new window, but when I select the group to pass to the form page and display the pop-up window will not close or populate the form field on the add form page. Any help would be appreciated.


ADD Form PHP Page Want to hide a readonly form field for a group name and display a button to search group listing from another page.


Form Field Page HTML Code



<div class="form-group">
<label class="col-sm-3 control-label" for="groupId">Group *</label>
<div class="col-sm-6" id="div_gr_name" style="<?php if ($gr_id < 1) {?> display:none <?php } else { ?> display:inline <?php } ?>">>
<input type='text' name='gr_name' class='span2 form-control' placeholder="Search Group Name" value="<?php if ($gr_id != -1) {echo $gr_name;} else {echo '';} ?>" id='gr_name' readonly='true' required/>
</div>
<div class="col-sm-2" style = "<?php if ($gr_id > 1) {?> display:none <?php } else { ?> display:inline <?php } ?>">
<button type="button" class="btn btn-primary" onclick='OpenPopup()'>Search</button>
</div>
<div>
<span id='paientNameMissing'></span>
</div>
</div>


Javascript OpenPopup from footer page



function OpenPopup() {
try {
window.open("searchgroup.php", "_blank", "width=850,height=500,scrollbars=yes,resizable=yes");
}

catch (ex) {
alert(ex);
}

finally {
event.cancelBubble = true;
event.returnValue = false;
return false;
}
}


Searchgroup Selection PHP Page


Group Selection Page PHP & HTML Code



//retrieve our table contents
while($row=mysql_fetch_array($rs)){
extract($row);
//creating new table row per record
echo "<tr>
<td>{$gr_name}</td>
<td>{$gr_leadername}</td>
<td>{$gr_leadcontact}</td>
<td>{$gr_leademail}</td>
<td>";?><a href='#' onclick="select_group('<?php echo $gr_id ?>', '<?php echo mysql_real_escape_string($gr_name); ?>') ">Select</a><?php echo "</td>
</tr>";
}
//end table
echo "</tbody>
</table>
</div>";
}


Select Group javascript function



function select_group( id, name ){
var selvalue = id;
var selvalue1 = name;
window.opener.document.getElementById('gr_id').value = selvalue;
window.opener.document.getElementById('gr_name').value = selvalue1;

if (id!=0) {
window.opener.document.getElementById('div_gr_name').style.display = "inline";
}

else {
window.opener.document.getElementById('div_gr_name').style.display = "none";
}

window.close();
}




Aucun commentaire:

Enregistrer un commentaire