Agent009
01-28-2008, 04:02 PM
Hai, I'm trying to submit a form using a popup, and transfer one of the values from the popup window to the main window for processing. This is what I have so far.
<?php
// Data queried before here, let use select a tool from list below
$tool_list = '<select name="tool_list">';
$tool_list .= '<option value = "0" >Select Lockpicking Tool</option>';
for( $i = 0; $i < count($info); $i++ ){
$tool_list .= '<option value = "'.$info[$i]['item_id'].'">' . $info[$i]['item_name'] . '</option>';
}
$tool_list .= '</select>';
?>
<SCRIPT LANGUAGE="JavaScript"><!--
function gettoolid(tool)
{
// Suppose to get the id of the selected tool from the list
this.toolid = document.popupForm.tool.options[document.popupForm.tool.selectedIndex].value;
return this.toolid;
}
function copyForm() {
// Suppose to send the selected item value back to main form and submit the form.
opener.document.lockpick.tool_id.value = gettoolid(document.popupForm.tool_list.value);
opener.document.lockpick.submit();
window.close();
return false;
}
//--></SCRIPT>
<body>
<FORM NAME="popupForm" onSubmit="return copyForm()">
<table width="100%" cellspacing="3" cellpadding="3">
<tr>
<td align="center">Select Lockpicking Tool<br><br><?=$tool_list;?><br><br>
<input type="button" name="lockpick_chest" value="Lockpick Chest!" onClick="copyForm()">
</td>
</tr>
</table>
</FORM>
But the form is not being submitted. If I take this part out
opener.document.lockpick.tool_id.value = gettoolid(document.popupForm.tool_list.value);
It dose sumbit, but I really need to send the item id back to the main form for processing. Any help on this?
<?php
// Data queried before here, let use select a tool from list below
$tool_list = '<select name="tool_list">';
$tool_list .= '<option value = "0" >Select Lockpicking Tool</option>';
for( $i = 0; $i < count($info); $i++ ){
$tool_list .= '<option value = "'.$info[$i]['item_id'].'">' . $info[$i]['item_name'] . '</option>';
}
$tool_list .= '</select>';
?>
<SCRIPT LANGUAGE="JavaScript"><!--
function gettoolid(tool)
{
// Suppose to get the id of the selected tool from the list
this.toolid = document.popupForm.tool.options[document.popupForm.tool.selectedIndex].value;
return this.toolid;
}
function copyForm() {
// Suppose to send the selected item value back to main form and submit the form.
opener.document.lockpick.tool_id.value = gettoolid(document.popupForm.tool_list.value);
opener.document.lockpick.submit();
window.close();
return false;
}
//--></SCRIPT>
<body>
<FORM NAME="popupForm" onSubmit="return copyForm()">
<table width="100%" cellspacing="3" cellpadding="3">
<tr>
<td align="center">Select Lockpicking Tool<br><br><?=$tool_list;?><br><br>
<input type="button" name="lockpick_chest" value="Lockpick Chest!" onClick="copyForm()">
</td>
</tr>
</table>
</FORM>
But the form is not being submitted. If I take this part out
opener.document.lockpick.tool_id.value = gettoolid(document.popupForm.tool_list.value);
It dose sumbit, but I really need to send the item id back to the main form for processing. Any help on this?