Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how come Java doesn't run?

Posted on 2008-10-01
8
Medium Priority
?
586 Views
Last Modified: 2013-12-13
How come my java script doesn't run? I get an error everytime I click on the button that is attached to function below. If I stick this same code in the middle of a php function or in the middle of the php module, it works. If I stick it in a javascript event like I did, it doesn't work.
<?php
require_once("vcl/vcl.inc.php");
//Includes
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");
 
//Class definition
class Unit1 extends Page
{
       public $Button1 = null;
       function Button1JSClick($sender, $params)
       {?>
       <script language="JavaScript"
         type="text/javascript">
         window.alert('Hi there');
       </script>
 
       <?php
 
       }
 
}
 
global $application;
 
global $Unit1;
 
//Creates the form
$Unit1=new Unit1($application);
 
//Read from resource file
$Unit1->loadResource(__FILE__);
 
//Shows the form
$Unit1->show();
 
?>

Open in new window

0
Comment
Question by:evault
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 22612842
PHP Code executes on the SERVER. JavaScript executes on the BROWSER.

By the time you come to click the button, PHP is long finished processing your code.

What is the error you get?
0
 
LVL 1

Author Comment

by:evault
ID: 22615498
The way Delphi for PHP is structured, the Java Script should run. It has built in Java events that can be scripted for any object on the web page. That is why I don't understand why it doesn't run. The specific error is Syntax err, line 15, char 8. Nomatter how alter lines 14 and 15, it gives me the same error message.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 22615666
Where/when does the error occur?

Can you do a view-source to see if it is a local JS error?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
evault earned 0 total points
ID: 22659655
Figured it out on my own. The function is actually a built-in java script function, thus eliminating the need for the tags identifying it as a java script.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 22668649
Can you show the correct code please?
0
 
LVL 1

Author Comment

by:evault
ID: 22669821
There's not much to it as I was trying to experiment with different ways of handling a button click. The function apparrently includes (behind  the scenes) all of the set up necessary for a java script to execute.
       function Button1JSClick($sender, $params)
       {?>
         window.alert('Hi there');

       <?php

       }
 
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 22670418
That looks just too good. Well done on finding the answer and thanks for posting the solution.
0
 
LVL 1

Author Comment

by:evault
ID: 22670494
Once I figured out the Delphi structure it was pretty much a no brainer; just remove the headers to the script (it is already expecting Java script) and viola!
One note of concern, however is that there doesn't seem to be a lot of support for Delphi for PHP at thepresent moment.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question