Killersites.com Homepage Welcome Guest   |   Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | User List  | Help


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 5
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 94556 times and has 4 replies Next Thread
Male farazaleem
Stranger




Joined: Feb 2, 2007
Post Count: 1
Status: Offline
Reply to this Post  Reply with Quote 
How to call javascript function from php code

Hi,
I wana call javascript function frm php code in my else block,i tried this way
<?PHP
if()
{
SOME CODE
}
else
{
echo "<script language=javascript>divclose()</script>";//divclose() function just

make this div style to none
}
?>


bt it didnt work.Help is required how can i call javascript function from php code,and i dont wana call this javascript function on any event like onClick() or onMouseOver().I want this fuction to be called when else block will run.Telling the bigger picture of my problem,my form is appearing in a div and i want to close this div(mydiv.style.display = "none") in javascript function,problem i m facing is i m unable to call a javascript function.Can any tell me an alternate way of how can i make my

div-display-style="none" using php code.

[Feb 2, 2007 1:31:14 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Male sambosoeng
Stranger



cambodia
Joined: Mar 4, 2007
Post Count: 1
Status: Offline
Reply to this Post  Reply with Quote 
biggrin Re: How to call javascript function from php code

Dear farazaleem! :) smile

I understand ur problem! so just try this for resolving!


<script language="javascript">
function divclose()
{
//your code;
}
</script>


<?

echo "<SCRIPT LANGUAGE='javascript'>divclose();</SCRIPT>";

?>

Hope this will help ur problem! smile good day. from me Soeng Sok Sambo , phnom penh , Cambodia.
[Mar 4, 2007 12:44:03 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest    sambosoeng    no    no [Link] Report threatening or abusive post: please login first  Go to top 
Male rfresh
Newbie




Joined: Jun 3, 2007
Post Count: 23
Status: Offline
Reply to this Post  Reply with Quote 
Re: How to call javascript function from php code

You may want your php js call at the end of an html tag:

<INPUT TYPE="text" NAME="frm_manual_add" onBlur="populateShortName();">

Generally, you'll want to do some js validation from an action on an html tag event.
----------------------------------------
RalphF
http://www.1849WebHosting.com
[Jun 13, 2007 7:20:54 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male winotosw
Stranger



indonesia
Joined: Aug 12, 2008
Post Count: 1
Status: Offline
Reply to this Post  Reply with Quote 
Re: How to call javascript function from php code

You can use http://satoewarna.com/jqsajax/ to call PHP method/function from javascript.
[Aug 12, 2008 11:33:07 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest    wins_ku [Link] Report threatening or abusive post: please login first  Go to top 
Male leegao
Member




Joined: Jul 11, 2007
Post Count: 65
Status: Offline
Reply to this Post  Reply with Quote 
Re: How to call javascript function from php code

Sorry for the late post.

The JS function name suggests to me that this script is intended to call an event on an element of the DOM. The main problem here is that if you're using any types of scripting library, the behavior must be bounded as an event before it can be called.
[Sep 26, 2008 12:17:29 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread