Troubles using Javascript popoup  inside a PHP file

I am trying something simple: to open a popup window trough a
javascript code inside my PHP file and nothing happens: here is the
code:
$openwindow =
"MM_openBrWindow('view.html','','width=300,height=300')";
echo "<td><a href='#'><img
src='images/button_blue.jpg' alt='Map' width='97' height='13'
border='0' onclick=" . $openwindow . "/></a></td>";
Also I am declaring such Javascript function at the beginning
of the file... Please help me as soon as you can... it is driving
me crazy... thanx in advance !

.oO(David Powers)
>Michael Fesser wrote:
>> print "<a
href='foo?id=$something'>bar</a>";
>>
>> Not a single escape character and very readable in
an editor with proper
>> syntax highlighting.
>
>I agree with Steve that this is a trivial example that
doesn't really
>prove anything.
OK. At least it shows that escaping is not always necessary
In a more complex example with more variables I would've used
printf().
>If $something is the only variable in a long section of
>HTML, it's much more efficient to do this:
>
><a href="foo?id=<?php echo $something;
?>">bar</a>
I don't think efficieny is really an issue here.
>Every time that the PHP engine encounters double quotes
inside a PHP
>block, the engine has to parse the content to find if any
variables are
>interpolated. In your example, there is a variable, so
the effort isn't
>wasted, but many developers use double quotes all the
time, even if no
>variable are included in strings. Although the difference
in processing
>time is only microseconds, it's an inefficient way of
writing PHP.
Did you ever encounter any performance issues just because of
using
"unneccesary" double quotes? Or by using string concatenation
instead of
the slightly faster
echo $foo, $bar, $somethingElse ?
I didn't, and I doubt I ever will. It may be not the best
style and
usually I use single quotes where possible, but I don't care
too much,
because other things are much more important.
In fact I consider that all rather esoterical. If someone
tries to
"optimize" his code by avoiding double quoted strings where
possible
then IMHO he doesn't really have understood optimization at
all. The
real bottlenecks are not some syntactical sugar provided by
PHP, but the
algorithms and I/O operations. That's where optimization has
to start.
>However, I've seen a lot of inexperienced people post
questions about
>PHP problems, usually caused by the incorrect mixture of
single and
>double quotes.
Agreed, me too. But often it's not just some lack of
knowledge, but also
the usage of the wrong tool. Many errors I've seen in
beginner's code
(especially the mentioned quoting problems) could've been
easily spotted
with proper syntax highlighting.
>When you ask why they have coded it in such a convoluted
>way, the answer is invariably "because it's a PHP page".
Hmm, quite possible.
>PHP is designed
>to be embedded in HTML.
True, but just because PHP is designed for this and that,
doesn't mean
that I always have to use it in that way. Remember
register_globals and
magic quotes - they were a fundamental part of PHP's design a
while ago.
>You can also include HTML in PHP functions.
Now it gets really nasty. That's even more ugly than heredoc
syntax. ;)
With HTML embedded in PHP functions I always had the problem
how to
indent the code - either the source code looked bad or the
final HTML.
I never did it again.
>If the HTML block contains a lot of variables or other
dynamic code, I
>agree that using print or echo is probably more efficient
and easier to
>read. However, when HTML is predominant, embed the
dynamic stuff.
As said - I consider it just personal preference. There are
valid
reasons for both ways.
Micha

Similar Messages

  • How to use multi queries inside the RTF file

    Hi all,
    I develope a data source in report developer 10g, and use it to create the RTF files... I have some files wich contains more than 1 query. how can I refer to the fileds in the other queries in side the RTF file, because it's bring the filed from the first query by default??
    ThanX in advance

    ThankX DD
    But that wont work for my case. the problem that I have actually is in RTF.
    for example:
    I have 3 qeuries. A,B & C. A: contains the employee data. B: his Earnings and C: his Deductions.
    in the RTF file it shows me only A contents. wich means it's not entring B & C loops, notice I add <?for-each:B_GROUP_NAME?> and same for C also.
    all my other reports wich have single qeury worked fine.
    Regards to all,
    Message was edited by:
    Adam Ali

  • Trouble using Javascript getElementById

    hello,
    unfortunately the great comfort of studio creator2 ends, wenn using javascript. I alway debugged it using firefox, but that doesn't seem to work here:
    Document.getElementsById("form1:totalCostTextField").value =
            document.getElementsById("form1:cost1TextField").value+
            document.getElementsById("form1:cost2TextField").value+
            document.getElementsById("form1:cost3TextField").value+
            document.getElementsById("form1:cost4TextField").value+
            document.getElementsById("form1:cost5TextField").value+
            document.getElementsById("form1:cost6TextField").value;as you can see i've got a form of some textfields recieving prices and i have to calculate the total price. A perfect job for javascript i thought. At first i discoverd that i have to integrate the form-Name (form1 here) to the id i specified, as Creator seems to put it in front of the elements id. I also found out, that using readonly turns an inputfield to a span-tag ( why so ever); i turned off readonly therefore ( as the ID will be appended "_readOnly").
    Well my problem is, that the onBlur-Event IS called ( proved by a simple alert). But nothing will be calculated. Normally FireFoxes Javascript-Console will show any errors. In this case it doesn't. Where am i wrong here. Are my Identifiers incorrect? Why can't i see any recalculating ?
    thank you
    wegus

    Hmmm..
    some errors here.
    - The method you have to call is getElementById, without the 's'.
    - The first Document must be with a lowercase 'd'
    - In JavaScript you have to explicitly convert an input text to number with parseInt() if you want to make some calculation
    Therefore, if I understand what you want to do, for example define a javascript function like:
    function sumValues(){
         var temp1 = parseInt(document.getElementById("form1:cost1").value);
            if (isNaN(temp1)) return;
            var temp2 = parseInt(document.getElementById("form1:cost2").value);
            if (isNaN(temp2)) return;
            var temp3 = parseInt(document.getElementById("form1:cost3").value);
            if (isNaN(temp3)) return;
            document.getElementById("form1:totalCost").value = temp1+temp2+temp3;
    }then add the function call to each text field's onBlur event.
    Any time that a field will lost its focus, then the sum will be recalculated.
    Ciao,
    Fabio

  • I'm having trouble using standard input inside JDB

    Hello Java(R) community
    The problem is:
    I cannot read a stream of characters from the keyboard inside JDB. Just to set context I'm using:
    jdk 1.3.1_01 with jdb version 99/06/11 under RedHat(R) Linux(R) 7.1
    I've written the following code:
    1:import java.io.*;
    2:
    3:public class Test {
    4:
    5: Reader reader = new InputStreamReader(System.in);
    6: char[] buffer = new char[256];
    7:
    8: public void myRead() {
    9:
    10: System.out.print("Insert some text: ");
    11: try {
    12: reader.read(buffer);
    13: }
    14: catch (IOException e) {
    15: System.out.println(e.getMessage());
    16: }
    17: System.out.println("You've inserted the following text: " + new String(buffer));
    18: }
    19:
    20: public static void main(String[] args) {
    21:
    22: Test ref = new Test();
    23: ref.myRead();
    24: }
    25:}
    The above is compiled with javac -g Test.java
    At the shell you run ' java Test ' and it just echoes the input you give to it
    Inside jdb you set a breakpoint with ' stop in Test.myRead()'. When there, it stops at line 10; you invoke the 'next' command and it just don't print the message (just becuse it's not a println it just don't flush I suppose); after that the next line to execute is 12; so you invoke 'next' again and the real problem happens! Nothing can be read from the standard input. If you try to run the 'list' command jdb says "Current thread isn't suspended".
    Does anyone knows what's going on?
    Thanks in advance for a reply.

    If you use the launching connector to start the debugee,
    (this is the default used when you start jdb)
    then jdb cannot tell the difference between jdb commands
    that you are typing, and other text you want sent to the
    debugee program. You will have the same problem with
    output going the other way. The debugee program output
    will be mixed in with any jdb output that comes along.
    This is because the controlling window has only one stdin,
    stdout, stderr that both processes (as well as anything else
    you are running in that window) are forced to share.
    You need to separate the debugger and debugee, as follows:
    1) Start the debugee program (HelloWorld in this example)
    in one command window:
    % java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=4571 HelloWorld
    2) In another window, attach your debugger (jdb in this example)
    to the debugee via a socket:
    % jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=4571
    You may also use the shared memory transport if you are
    on a win32 platform, as follows:
    1) In one command window:
    % java -Xdebug -Xrunjdwp:transport=dt_shmem,server=y,address=mine HelloWorld
    2) In a second command window (again using jdb as an example):
    % jdb -connect com.sun.jdi.SharedMemoryAttach:name=mine
    For more information, refer to "Connection and Invocation Details"
    at this URL:
    http://java.sun.com/j2se/1.4/docs/guide/jpda/conninv.html

  • To add the JNI dll to the jar file and use the dll inside the jar file

    Hi to everybody,
    I am new to java.
    I want to add the JNI dll to the jar file and use it in the java class.
    How can I achieve it.
    Please help me.
    Thanks in advance.
    Regards,
    M.Sivadhas.

    can't be done because none of the known operating systems support reading binary libraries from .jar files ... you can add the binary to the jar but then you have to extract it...
    besides, mixing platform specific and platfrom independent components is not a very good idea, i'd keep the dll out of the jar to begin with

  • Use javascript inside page fragment

    Im trying to use javascript code inside a page fragment with the tag
    af:resource
    But the second time the page reloads i got this error: "ReferenceError: funciona is not defined"
    <af:resource type="javascript">
          function funciona() {
              alert(123);
    </af:resource>
    Im using JDeveloper 12c

    The resource is added to the af:document component to be included when the document is rendered. The resource is only processed on the initial creation of the document.
    are you sure, af:resourse tag presence under af:document.?

  • How to add a comment in a php file which has html code

    Hi
    I have a html file which I renamed .php after adding a form. I discovered that the html comment text I was using - <!--this is a comment --> - was affecting how the page rendered, particularly in IE9.
    My question is, now that it is a php file do I need to change all the comments syntax? I started to do it using the "apply comment" button in CS5 i.e. syntax: <?php /*?>form<?php */?>.
    Is this the right way to do it? It gives "php" icons in design view but appears to render ok.
    Thanks

    PHP comments:
    <?php
    //This is a comment
    This is
    a php comment
    block
    ?>
    Use PHP comments inside PHP scripts/code.
    HTML comments:
    <!--comment-->
    <!--this is
    an html comment
    block-->
    Use HTML comments inside HTML code.
    CSS Comments:
         /*comment*/
         /*this is
         a css comment
         block*/
    Use CSS comments inside CSS code (either embedded or external).
    JavaScript comments:
    //this is a single line comment
    //this is another single line comment
    /*this is a multi-line
    javascript
    comment
    Use JavaScript comments inside JavaScript code (either embedded or external).
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • Can't edit php files in dreamweaver, access to site root denied

    Can anyone help me please?
    I've recently purchased a Macbook Pro after my PCs failed on me and also had to get a Creative Suite Web Premium. I have always used Dreamweaver to edit my php files. In Windows XP, I had to run the programme to run as an Administrator to edit php files. Now I have not a clue how to do it on Mac! Each time I tried to save a php file, a dialog box appear stating: Access to Macintosh
    HD:Library:Webserver:Documents:Untitled-1.php was denied
    Regards
    Sinead

    You shouldn't have to do that on the Mac or Windows.  Only thing I could find that would suggest loading files from there is a tutorial by David.  And although I would normally agree with him, keeping the files in a system library folder for a testing environment is really unnecessary.  I'd recommend moving them into your /Users/{username}/Sites folder.  There is already a modification to the apache server to recognize that as http://localhost/~{username}.  Or install something like MAMP that is in the Applications folder.

  • How to Read a External File in a livecycle form (using javascript)

    Hi Everyone,
       First of all, i would like to thank you in advanced for your help !!
       I have a situation were i need to load some values into some fields inside a dinamic pdf that was created in livecycle, what can i do so far ?
       I can load the fields with some values using a livecycle event and javascript, the values come from some functions that i have created but ... are fixed of course...
    What i need is to load up the values from the outside world.... from a external file (text or xml) or a webservice... i have some several experiences but nothing has worked so far...
    Can anyone publish a sample code in javascript to load up a file (text or xml) that works inside livecycle ??
    Thanks in advanced.
    Miguel Angelo (migas)

    Hi, Paul,
      Thanks i have looked inside the link (dam big ) but i'm still kind of lost, can anyone please publish a code example ?
    Miguel

  • Is it possible to use JavaScript to search a directory of PDF files?

    A company I am interning for is looking for a solution. They want to allow users to search within their PDF user manuals by typing a string into a search field and returning the PDF document link or page link. Is this possible? How would I accomplish this? I have only been programming for 1 year.
    Can adobe reader use javascript to create a link that we attach the directory to? If not how or what would you do?
    Thank you.

    Ideally, I would like a link to Adobe Reader or Acrobat that only allows users to "Search Our Manuals for Help".  The user types in "Commission Invoice Inquiry" and in return gets links etc. to the PDF's in our directory of files containing that inquiry or "string".
    User scenario:  User gets new software from company but needs to look in manual on how to get "commision invoice inquiry". So user goes onto my company's website and finds this said application I am looking for and types in "commission invoice inquiry" and hits enter. The application then searches through the company's directory of PDF files (manuals) for "commission invoice inquiry" and returns any page links within the PDF that have that "commission invoice inquiry" on them. It can open inside of Adobe Reader or Acrobat or whichever. The company is even willing to pay for said "plugin" or application.

  • Use gvim to edit text areas and get it to use javascript.vim syntax file

    I have had a lot of trouble with javascript and editting files via apex's "javascript" sections in the page.
    The font in firefox did not distinguish various braces well enough for me. I kept accidentally mixing curly braces and parens... And I would now and then put the plsql concatenate operator || instead of the javascript +. Bleah! There are SO many ways to completely break javascript. And the whole javascript herd goes down when just one little function anywhere in there has an errant brace or quote. So I started resenting not using my customary text editor gvim. I have to have this stuff colorized and have showmatch turned on!
    So anyway I found that you can edit textareas with gvim, I don't know if this is commonly known or not so
    I thought I'd mention it. Or you can use whatever editor you want.
    I only tried this on windows but theoretically it works on other operating systems modulo you
    adjusting the shell details appropriately.
    First of all install the"It's all text!' firefox extension and restart firefox.
    then create a batch file something like this:
    (NB: don't call a batch file the same name as an executable. That can cause pesky loops :-)
    gvimrun.bat:
    c:\vim\vim73\gvim.exe %1 -c "set filetype=javascript"
    Note the pathname to gvim.exe needs to be customized. Note the parameter for passing the first argument along. (%1) The set filetype is telling it effectively to use the c:\vim\vim73\syntax\javascript.vim file.
    so then when you bring up your page in apex , when you put the mouse cursor right below the
    down arrow of the vertical scrollbar on the rhs of the textarea, you should see a little blue button
    that says "edit". Then right click and choose preferences. Direct it to your batch file.
    And if all is well it will work and invoke gvim with syntax coloring. Which makes it just a tiny bit less likely to really flub it.
    Now if anyone else wants to pick up the baton and figure out how to get more than one syntax
    in effect such as javascript and jquery? I did find a jquery.vim file out there. ...
    Now that we know how to do this if someone knows some really super great javascript /jquery
    editor that might be way better than gvim I would definitely consider that! Javascript is easy to screw up
    Edited by: lake on Jan 2, 2011 11:34 AM

    Hi Mathan. Here is something i have trying to do. This vi does not write it correct... and have I done something wrongly or "stupidly" in code
    Problems:
    -Second row is inroccet
    -If i know that device returns array where is 10 elements. Can I trust that and just return 10 elements from array and changed it to string?
    -Can I trust queue in this way?
    I think hardest in labview coding is that you dont know what kind component you should use and what is the right way to use them.
    Attachments:
    array to file.vi ‏21 KB

  • Unable to update rating (rating column) on host document using JavaScript Object Model API inside sharepoint hosted apps

    Hi Everyone,
    We are developing SharePoint hosted apps for Office 365, for that we are going
    to implement document rating functionality inside Sharepoint app. The host web contain document library (“Documents”) and from apps we need to rate each document. The rating functionality working fine with CQWP in team site  using
    JavaScript Object Model API.
    But the same code is not working inside apps and giving error:-
    If we are using app context than error will be:-
    "List does not exist.
    The page you selected contains a list that does not exist.  It may have been deleted by another user."
    And for Host context than error will be:-
    "Unexpected response data from server."
    Please help on this
    Please see below code..
    'use strict';
    var web, list, listItems, hostUrl, videoId, output = "";
    var videoLibrary = "Documents";
    var context, currentContext;
    var lists, listID;
    var list, parentContext;
    var scriptbase;
    (function () {
        // This code runs when the DOM is ready and creates a context object which is 
        // needed to use the SharePoint object model
        $(document).ready(function () {
            hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
            context = SP.ClientContext.get_current();      
            SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
        function sharePointReady() {
            scriptbase = hostUrl + "/_layouts/15/";
            // Load the js files and continue to the successHandler
            $.getScript(scriptbase + "SP.Runtime.js", function () {
                $.getScript(scriptbase + "SP.js", function () {
                    $.getScript(scriptbase + "SP.Core.js", function () {
                        $.getScript(scriptbase + "reputation.js", function () {
                            $.getScript(scriptbase + "sp.requestexecutor.js", execCrossDomainRequest);
        //Query list from hostweb
        function execCrossDomainRequest() {       
            //Load the list from hostweb
            parentContext = new SP.AppContextSite(context, hostUrl);
            web = parentContext.get_web();
            list = web.get_lists().getByTitle(videoLibrary);
            context.load(list, 'Title', 'Id');
            var camlQuery = new SP.CamlQuery();
            camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name="Modified" Ascending="FALSE"/></OrderBy></Query><RowLimit>1</RowLimit></View>');
            listItems = list.getItems(camlQuery);        
            context.load(listItems);
            context.executeQueryAsync(onQuerySucceeded, onQueryFailed);
        //Process the image library
        function onQuerySucceeded() {       
            var lstID = list.get_id();
            var ctx = new SP.ClientContext(hostUrl);       
            var ratingValue = 4;
            EnsureScriptFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function() {      
            Microsoft.Office.Server.ReputationModel.Reputation.setRating(ctx, lstID, 1, ratingValue);       
            ctx.executeQueryAsync(RatingSuccess, RatingFailure);
        function onQueryFailed(sender, args) {
            alert('Failed' + args.get_message());
        function failed(sender, args) {
            alert("failed because:" + args.get_message());
        function RatingSuccess() {
            alert('rating set');
            //displaystar();
        function RatingFailure(sender, args) {
            alert('Rating failed : : ' + args.get_message());
        //Gets the query string paramter
        function getQueryStringParameter(paramToRetrieve) {
            var params;
            params = document.URL.split("?")[1].split("&");
            for (var i = 0; i < params.length; i = i + 1) {
                var singleParam = params[i].split("=");
                if (singleParam[0] == paramToRetrieve) return singleParam[1];
    Thanks & Regards
    Sanjay 
    Thank you in advance! :-)
          

    Hi,
    According to your post, my understanding is that you want to update list column in SharePoint hosted apps using JavaScript Client Object Model.
    Based on the error message, it seems not retrieve the list object in context. I suggest you debug the code step by step using Internet Explorer Developer Tools to
    find the problem.
    Here are some demos about using JavaScript Client Object Model in SharePoint hosted app:
    http://blogs.msdn.com/b/officeapps/archive/2012/09/04/using-the-javascript-object-model-jsom-in-apps-for-sharepoint.aspx
    http://sharepoint.stackexchange.com/questions/55334/how-to-access-list-in-sharepoint-hosted-app
    http://www.dotnetcurry.com/showarticle.aspx?ID=1028
    Best regards
    Zhengyu Guo
    TechNet Community Support

  • How to read and write Xml file at client side using JavaScript !

    Hello,
    i am new to javascript.
    I have requirement to read and update XML file at client side.
    Will you please guide what could be the best way to read and update XMl file using javascript.
    Thanks,
    Zuned

    This is a Java forum,not a Javascript forum. Maybe you should ask here [http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s|http://www.webdeveloper.com/forum/forumdisplay.php?forumid=3&s].

  • Why this site used php files in all the pages?

    Hola
    I download my friend's site and ALL the pages are in a folder with the file name index.php ... WHY?
    Example;
    Name of folder; gallery
    Inside this folder, a file with the name index.php
    Name of folder; contact
    Inside this folder, a file with the name index.php
    It has an "includes" folder with files for ;
    header.php, footer.php, content.php and functions.php
    and so on.
    Now, this site has ONLY 7 pages, it's not like it's a monster site, so
    what is the purpose of using php in every single page?
    I have to tell you that my friend has a program call CKeditor and CKfinder to
    edited her website.
    Not sure if this is the reason why this site has been coded all of it with php files.
    I'm waiting impatiently for your responce

    >Now, this site has ONLY 7 pages, it's not like it's a monster site, so
    >what is the purpose of using php in every single page?
    The reason for using php extension or not has absolutely nothing to do with the size of the site. If the site uses dynamic pages, then the page need a dynamic page extension. Even sites without dynamic pages often use .php in anticipation of using them so the file names won't need to be changed down the road.
    Now, if your question is more about why they created separate directories for each page, it's probably so the url's can be accessed without including the file extension, Ex
    example.com/contact
    instead of
    example.com/contact.php

  • How to Use PHP Files and .tpl files

    I have taken a course and it includes a resource section with templates that I can use. These templates are squeeze page ones and inside the folder are index.php, config.php and a whole lot of .tpl files that open up in empty Stickies on my Mac.
    Can someone explain how to use these files. When I open them in Dreamweaver I see code related to the php files but I can't browse the index.php file in a browser to see what the so called sqeeze page looks like.
    Yikes I'm really lost here.
    thanks
    John

    ORA-06401, 00000, "NETCMN: invalid driver designator"
    Cause: The login (connect) string contains an invalid driver designator.
    Action: Correct the string and re-submit.
    The //ip:port/sid connect string will only work with 10g clients.
    Check your tnsnames.ora file. Does the file have control characters or missing carriage-return characters ? (Maybe you ftp'd the file from a unix box ?)
    I would suggest that you create a new tnsnames.ora - hand edit it (don't copy the old one). If you have sqlplus client - try using it to connect to the remote DB first.
    The instructions for connection to a local or remote DB are all the same (when using plain OCILogon) because the connection is made over TCP.

Maybe you are looking for

  • How to add a hyperlink to javamail attachment?

    Hi friends: I am writing a mail systems.I can receive email attachment using javamail API. But I don't know how to add a hyperlink to the attachment so when user click the hyperlink the file will be download to disc. I means that I want to add a hype

  • ISE 1.3 - logging admin actions like CoA

    Hi all, I'm trying to find a way to gather the logs regarding admin action. To be more specific: If there is an admin who performs CoA from "Live Authentications" view, I want to have a proof that this guy did it. I tried to find any report on such a

  • When down loading updates, im ask what program to open it up with

    when down loading the updates my computer ask me what program i want to open it with?

  • Supports Design View in Linux ?

    Hi All, am new to Flex and am using ubuntu os(Linux) . I have downloaded and installed Flex Builder alpha version for Linux and i read that Linux doesn't support Design View and some other views for Flex Builder from the following URL: http://labs.ad

  • Why does Photoshop CS5 Extended (Mac) keep randomly freezing?

    I'm running Photoshop CS5 Extended for Mac. I've had it for over a year now and it has worked perfectly fine until now. Mac OS X Version 10.6.8 Processor: 2.4 GHz Intel Core 2 Duo Memory: 4 GB 1067 MHz DDR3 The issue started a few weeks ago. I can't