|
Posted by IchBin on 07/14/06 00:04
David Haynes wrote:
> Chuck Anderson wrote:
>> David Haynes wrote:
>>> Chuck Anderson wrote:
>>>
>>>> monomaniac21 wrote:
>>>>
>>>>> hi i want to be able to trigger a javascript style popup alert in php
>>>>> (i want a message displayed on the actual page) is this possible?
>>>>>
>>>>>
>>>> I'll take this one ... all I usually do here is ask questions.
>>>>
>>>> The answer to your question is No. Php is run on the *server before*
>>>> the page is displayed. Therefore, Php cannot popup an alert like
>>>> JavaScript (which runs on the *client computer after* the page is
>>>> loaded).
>>>>
>>>> That said; if you want to implement a two step procedure like
>>>>
>>>> (1) Delete this file.
>>>> (2) Are you Sure (Y or N)?
>>>>
>>>> You can do that with Php, but clicking on (1) must create a request
>>>> to the server to display a new page with (2) as a form or
>>>> hyperlinks. Clicking on Y or N must return to the server again in
>>>> able to perform the action.
>>>>
>>>>
>>> or you can have the php spit out the javascript as part of the page and
>>> trigger it from the onclick= in the submit.
>>>
>>> -david-
>> But that's not "triggered in Php" and is simply JavaScript.
>>
> Yes, but you had already provided "you can't get there from here"
> answer. Sometimes it pays to offer alternatives rather than just to
> answer the question someone has asked.
>
> -david-
>
I am following this thread because I am trying to do the same thing.
Problem is I do not know php\javascript all that well. I had posed my
code to this newsgroup but received no answer. So I do not know if I can
do what I am trying to do or I am just so far off that it does not
warent an answer. This is what I have so far. I can not get to work and
have comment out what I am trying:
//
// Handle the data coming back
echo '<FORM NAME=author method=post action='.$_SERVER['PHP_SELF'].'>';
//echo '<SELECT NAME=author_pk SIZE=20 COLS=20 ONCHANGE='.$_POST[id].'>';
//echo '<SELECT NAME=author_pk SIZE=20 COLS=20 ONCHANGE=getPK()>';
echo '<SELECT NAME=author_pk SIZE=20 COLS=20>';
while ($rows = mysql_fetch_object($result)) {
echo '<OPTION VALUE='.$rows->id.'>'.
$rows->TITLE.' '.
$rows->lastname.', '.
$rows->firstname.
$rows->middlename.
$rows->SUFFIX.
'</OPTION>';
}
echo '</SELECT>';
echo '</FORM>';
//echo '<script language=Javascript>';
//echo 'function getPK() {';
//echo
"document.author.author_pk.options[document.author.author_pk.selectedIndex].value
";
//echo '}';
//echo "</script>";
--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
[Back to original message]
|