How to change value of input on form from iframe?
| From: | Dezider Góra | Date: | Mon, 14 May 2001 12:35:28 +0000 |
| Subject: | How to change value of input on form from iframe? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-52686@lists.php.net to get a copy of this message | ||
I'm having a big problem.
I've created "bound" combo's page, that works. When user selects a value
from first combo, second combo in IFRAME is requeried and shows only
corresponding values.
Now I need to get the value from the second combo back to the main form.
I'm trying all javasrcipt combinations that come to my mind, but with no
succes.
Can PLEASE anybody show me the correct syntax?
tia
Dezider.
the main page:
<HEAD>
<?
echo "<SCRIPT LANGUAGE=\"JAVASCRIPT\">";
echo "function requery(country_id)";
echo "{";
echo "document.all.operator.src=\"getoperators.php?id=\" + country_id;";
echo "}";
echo "</SCRIPT>";
?>
</HEAD>
<BODY>
.
.
.
<TD WIDTH="150"><B>Operátor</B></TD>
<TD>:</TD>
<TD><IFRAME name="operator" "id="operator"
SRC="getoperators.php" FRAMEBORDER=NO SCROLLING=NO HEIGHT="22"
WIDTH="200"></IFRAME></td>
</TR>
<TR>
<TD COLSPAN="3">
<INPUT TYPE="HIDDEN" NAME="operatorid" id="operatorid"
VALUE="0">
<input type="SUBMIT" value="Send">
</td>
</TR>
getoperators.php is:
<HTML>
<HEAD>
<SCRIPT language="Javascript">
function savevalue(oper_id)
{
alert (oper_id)
document.forms["newphone"].operatorid.value=oper_id;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PLEASE how to correct this?
}
</SCRIPT>
</HEAD>
<?
include "../../include/data_mysql.php";
$objData = new mysql_db;
$objData->init();
$sqlstring = "select * from cell_operators where country = $id";
$obj_str = "<SELECT NAME=\"operid\" TABINDEX=\"1\" SIZE=\"1\"
style=\"position: absolute; top: 0px; left: 0px\"
onChange=\"savevalue(this.value)\"><OPTION VALUE=\"0\">nie
je</OPTION>";
if ( $objData->query($sqlstring) ):
# Create a list from results
while ( $objData->movenext() == False ){
$obj_str .= "<OPTION VALUE=\"" . $objData->value( "id" )
.
"\">" . $objData->value( "cell_prefix" ) . ' - ' .
$objData->value(
"description" ) . "</OPTION>";
}
endif;
$obj_str .= "</SELECT>";
echo $obj_str;
?>