[ciapug] PHP/Java

Barry Von Ahsen ciapug@cialug.org
Thu, 15 Jan 2004 12:57:18 -0600


Correct, have the PHP write the javascript, and by the time the client 
browser sees it, it's just javascript (just like PHP writing html)

in the end the browser interprets whatever php spits out, so
<? echo "javascript:document.body.println(\"Hello world\")"; ?>
is no different than
<? echo "<p>Hello world!</p>"; ?>
to php, but it is to the browser.


-barry

Dave J. Hala Jr. wrote:
> 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