[ciapug] PHP/Java

Dave J. Hala Jr. ciapug@cialug.org
15 Jan 2004 12:25:17 -0600


Interesting idea.  So basically, I'm embedding the javascript in the PHP
(like you do with HTML) and then assigning the PHP value to the
jasvscript value, right?


On Mon, 2004-01-12 at 10:04, Barry Von Ahsen wrote:
> Dave J. Hala Jr. wrote:
> 
> > Here's a good one for monday morning:
> > 
> > I have a php script. The scripts reads some values from a mysql table
> > and creates a listbox. Next to the listbox is an input field.
> > What I'd like to do is have a small javascript that inserts a default
> > value into the input field according to the option that was selected
> > from the listbox.   The problem is that the values for the input field
> > also come from a mysql table.
> > 
> > My question is, can the javascript use the data from a php array?
> 
> it can if you use PHP to write the javascript:
> <script language="javascript">
> <?
> echo "jsArray = new Array(";
> echo "\"".$inputvalue."\"";
> $recordset->MoveNext();
> while (!$recordset->EOF) {
> 	echo ", \"".$inputvalue."\"";
> 	$recordset->MoveNext();
> }
> echo ")"
> // or echo "jsArray = new Array(\"".implode("\", \", $phpArray)."\")";
> ?>
> document.form.inputbox.value = 
> jsArray[document.form.listbox.selecteditem.value];
> </script>
> 
> I'm sure my javascript is incorrect, but (hopefully) you get the idea
> 
> -barry
> _______________________________________________
> ciapug mailing list
> ciapug@cialug.org
> http://cialug.org/mailman/listinfo/ciapug
-- 

"...Unix, MS-DOS and Windows NT (also known as the Good, the Bad, and the Ugly)"

OSIS
Dave J. Hala Jr.
641.485.1606