Re: How to change value of input on form from iframe?

From: Date: Mon, 14 May 2001 23:04:03 +0000
Subject: Re: How to change value of input on form from iframe?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-52689@lists.php.net to get a copy of this message
Hi! Never worked with IFRAMEs nor sure how i can access their forms with JavaScript? maybe it's like: framename.document.formane.field ? anyway.... As i understand: * Main form have Combo1 that when it's selection is changed then IFRAME.Combo2 is rebuilt right? I see you set your frame source to myframe.php?id=id_from_combo1 Now when the main page is reloaded you must have a variable called $id too, So basically as the Combo1 have <option> and you need to position the last one before the form was posted then make use again from the $id variable. like for example: after the main form has been loaded, generate this script: <script> document.mainform.combo1.selectedIndex = <?=$id?>; </script> This was an example.... Hope i help a little. -elias "Dezider Góra" <gora@wittmann.sk> wrote in message news:3AFFD110.CD569924@wittmann.sk... > 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; > ?> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#52689) next »