How to use javascript in php?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shang Wenbin

    #1

    How to use javascript in php?

    Hi,

    How to use javascript in php?
    I want to return some values to php.
    Thanks

    --
    Shang Wenbin from Realss
  • Evertjan.

    #2
    Re: How to use javascript in php?

    Shang Wenbin wrote on 25 apr 2005 in comp.lang.javas cript:[color=blue]
    > Hi,[/color]

    Hi too
    [color=blue]
    > How to use javascript in php?[/color]

    You cannot. PHP does not support JS.
    However, ...
    [color=blue]
    > I want to return some values to php.[/color]

    if you are asking how to send a clientside javascript value
    to serverside [PHP, ... ]:

    <form id=f method=post>
    <input type=hidden name=JSvalue id=h>
    </form>

    .....

    document.getEle mentById('h').v alue="Hello"
    document.getEle mentById('f').s ubmit()

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)

    Comment

    • clarket@eircom.net

      #3
      Re: How to use javascript in php?

      You need to embed the he javascript into your php.

      e.g.

      echo "<html><body><h ead>";
      echo "<script LANGUAGE=\"Java Script1.4\" type=\"text/javascript\"">;
      echo "function sayHello(){";
      echo "alert(\"hello\ ");";
      echo "</script></head></body></html>";

      Comment

      • Ash

        #4
        Re: How to use javascript in php?

        Or you could perhaps gather your results in clientside Javascript, and pass
        the values back to the PHP by refreshing the page and passing the results as
        part of the Querystring?

        Cheers, Ash

        <clarket@eircom .net> wrote in message
        news:1114426052 .754178.284560@ z14g2000cwz.goo glegroups.com.. .[color=blue]
        > You need to embed the he javascript into your php.
        >
        > e.g.
        >
        > echo "<html><body><h ead>";
        > echo "<script LANGUAGE=\"Java Script1.4\" type=\"text/javascript\"">;
        > echo "function sayHello(){";
        > echo "alert(\"hello\ ");";
        > echo "</script></head></body></html>";
        >[/color]


        Comment

        • Evertjan.

          #5
          Re: How to use javascript in php?

          wrote on 25 apr 2005 in comp.lang.javas cript:[color=blue]
          > You need to embed the he javascript into your php.[/color]

          1 please quote the text you are answering on, this is usenet.

          2 why embed?
          [color=blue]
          > echo "<html><body><h ead>";
          > echo "<script LANGUAGE=\"Java Script1.4\" type=\"text/javascript\"">;
          > echo "function sayHello(){";
          > echo "alert(\"hello\ ");";
          > echo "</script></head></body></html>";
          >[/color]



          --
          Evertjan.
          The Netherlands.
          (Replace all crosses with dots in my emailaddress)

          Comment

          • Ash

            #6
            Re: How to use javascript in php?

            > 1 please quote the text you are answering on, this is usenet.

            Why are there always picky arseholes such as yourself within Newsgroups?? it
            is quite clear what Evertjan is suggesting, he has interpreted 'Shang
            Wenbin''s original post as "...how to utilise 'clientside' javascript..." as
            opposed to 'serverside', in which case his example is quite clear.

            If you haven't got anything positive to post that will aid an enquiry,
            simply do not post.

            Shang Wenbin, does the above answer your query?

            Cheers, Ash


            Comment

            • Martin Bialasinski

              #7
              Re: How to use javascript in php?

              "Ash" <spam_ash@a-hall.com> wrote:
              [color=blue]
              > If you haven't got anything positive to post that will aid an
              > enquiry, simply do not post.[/color]

              Right so.
              [color=blue]
              > Shang Wenbin, does the above answer your query?[/color]

              You didn't give any answer in your post.

              Bye,
              Martin

              Comment

              • @sh

                #8
                Re: How to use javascript in php?

                > If you haven't got anything positive to post that will aid an enquiry,[color=blue]
                > simply do not post.[/color]

                ....see above post.


                "Martin Bialasinski" <agr30+news@u ni-koeln.de> wrote in message
                news:87r7gxken6 .fsf@haitech.ma rtin.home...[color=blue]
                > "Ash" <spam_ash@a-hall.com> wrote:
                >[color=green]
                >> If you haven't got anything positive to post that will aid an
                >> enquiry, simply do not post.[/color]
                >
                > Right so.
                >[color=green]
                >> Shang Wenbin, does the above answer your query?[/color]
                >
                > You didn't give any answer in your post.
                >
                > Bye,
                > Martin[/color]


                Comment

                • Martin Bialasinski

                  #9
                  Re: How to use javascript in php?

                  "@sh" <spam_ash@a-hall.com> wrote:
                  [color=blue][color=green]
                  >> If you haven't got anything positive to post that will aid an enquiry,
                  >> simply do not post.[/color]
                  >
                  > ...see above post.
                  >
                  >
                  > "Martin Bialasinski" <agr30+news@u ni-koeln.de> wrote in message
                  > news:87r7gxken6 .fsf@haitech.ma rtin.home...[color=green]
                  >> "Ash" <spam_ash@a-hall.com> wrote:
                  >>[color=darkred]
                  >>> If you haven't got anything positive to post that will aid an
                  >>> enquiry, simply do not post.[/color]
                  >>
                  >> Right so.
                  >>[color=darkred]
                  >>> Shang Wenbin, does the above answer your query?[/color]
                  >>
                  >> You didn't give any answer in your post.
                  >>
                  >> Bye,
                  >> Martin[/color][/color]

                  The post above is <3d4b6kF6rj08kU 1@individual.ne t>

                  !* [ 14: Dietmar Meier ] Re: html drop down menus & adding an item to the a list.

                  Could you elaborate?

                  Bye,
                  Martin

                  Comment

                  • @sh

                    #10
                    Re: How to use javascript in php?

                    Refering back to my original post...
                    [color=blue]
                    > Why are there always picky arseholes such as yourself within Newsgroups??[/color]

                    Point proven...


                    Comment

                    • Randy Webb

                      #11
                      Re: How to use javascript in php?

                      Ash wrote:
                      [color=blue][color=green]
                      >>1 please quote the text you are answering on, this is usenet.[/color]
                      >
                      >
                      > Why are there always picky arseholes such as yourself within Newsgroups??[/color]

                      Because there are always stupid idiots like you within Newsgroups.
                      [color=blue]
                      > it is quite clear what Evertjan is suggesting,[/color]

                      Evertjan is the one that requested some non-quoting idiot quote what
                      they are replying to. Perhaps you should re-read what it is that you are
                      babbling about.
                      [color=blue]
                      > he has interpreted 'Shang Wenbin''s original post as "...how to
                      > utilise 'clientside' javascript..." as opposed to 'serverside', in
                      > which case his example is quite clear.[/color]

                      Actually, its not, but you wouldn't understand that.
                      [color=blue]
                      > If you haven't got anything positive to post that will aid an enquiry,
                      > simply do not post.[/color]

                      This is Usenet. Get used to it, move on. And, read a groups FAQ before
                      posting here. Ours (comp.lang.java script) is posted here many many times
                      a day in URL form, and 3 times a week in text form. In fact, it was
                      posted yesterday. Search the archives of c.l.j for "FAQ Poster".


                      [color=blue]
                      > Shang Wenbin, does the above answer your query?[/color]

                      Are you as stupid as you act/seem to be? Your "above" has nothing to do
                      with the "query".

                      --
                      Randy

                      Comment

                      • @sh

                        #12
                        Re: How to use javascript in php?

                        Yet again, refering back to my original post...
                        [color=blue]
                        > Why are there always picky arseholes such as yourself within Newsgroups??[/color]

                        Point proven...

                        No wonder the poor chap (Shang) has left the thread!

                        Cheers, Ash


                        "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
                        news:eLGdnWJ2dO PDXPPfRVn-hA@comcast.com. ..[color=blue]
                        > Ash wrote:
                        >[color=green][color=darkred]
                        >>>1 please quote the text you are answering on, this is usenet.[/color]
                        >>
                        >>
                        >> Why are there always picky arseholes such as yourself within Newsgroups??[/color]
                        >
                        > Because there are always stupid idiots like you within Newsgroups.
                        >[color=green]
                        >> it is quite clear what Evertjan is suggesting,[/color]
                        >
                        > Evertjan is the one that requested some non-quoting idiot quote what they
                        > are replying to. Perhaps you should re-read what it is that you are
                        > babbling about.
                        >[color=green]
                        >> he has interpreted 'Shang Wenbin''s original post as "...how to utilise
                        >> 'clientside' javascript..." as opposed to 'serverside', in which case his
                        >> example is quite clear.[/color]
                        >
                        > Actually, its not, but you wouldn't understand that.
                        >[color=green]
                        >> If you haven't got anything positive to post that will aid an enquiry,
                        >> simply do not post.[/color]
                        >
                        > This is Usenet. Get used to it, move on. And, read a groups FAQ before
                        > posting here. Ours (comp.lang.java script) is posted here many many times a
                        > day in URL form, and 3 times a week in text form. In fact, it was posted
                        > yesterday. Search the archives of c.l.j for "FAQ Poster".
                        >
                        > http://www.jibbering.com/faq/
                        >[color=green]
                        >> Shang Wenbin, does the above answer your query?[/color]
                        >
                        > Are you as stupid as you act/seem to be? Your "above" has nothing to do
                        > with the "query".
                        >
                        > --
                        > Randy[/color]


                        Comment

                        • Dr John Stockton

                          #13
                          Re: How to use javascript in php?

                          JRS: In article <d4l0vp$okj$1@t itan.btinternet .com>, dated Tue, 26 Apr
                          2005 09:17:45, seen in news:comp.lang. javascript, Ash <spam_ash@a-
                          hall.com> posted :[color=blue][color=green]
                          >> 1 please quote the text you are answering on, this is usenet.[/color]
                          >
                          >Why are there always picky arseholes such as yourself within Newsgroups?? it
                          >is quite clear what Evertjan is suggesting, he has interpreted 'Shang
                          >Wenbin''s original post as "...how to utilise 'clientside' javascript..." as
                          >opposed to 'serverside', in which case his example is quite clear.
                          >
                          >If you haven't got anything positive to post that will aid an enquiry,
                          >simply do not post.[/color]


                          If you want help from the experts here, it behoves you to act in a
                          manner which pleases the experts here. If you choose not to do that,
                          they are rather likely to choose not to help you. Complaining in that
                          manner is a good way to get yourself noticed as the sort of person who
                          is best left for the incompetent to answer.

                          --
                          © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME ©
                          Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
                          Web <URL:http://www.merlyn.demo n.co.uk/news-use.htm> : about usage of News.
                          No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

                          Comment

                          • Thomas 'PointedEars' Lahn

                            #14
                            Re: How to use javascript in php?

                            Shang Wenbin wrote:
                            [color=blue]
                            > How to use javascript in php?[/color]

                            Depends. Client-side JS or server-side JS? Client-side or server-side PHP?
                            [color=blue]
                            > I want to return some values to php.[/color]

                            Could you please be more specific?


                            PointedEars

                            Comment

                            • Thomas 'PointedEars' Lahn

                              #15
                              Re: How to use javascript in php?

                              clarket@eircom. net wrote:
                              [color=blue]
                              > You need to embed the he javascript into your php.[/color]

                              No, he does not. It is one way, but it is not the only one.
                              [color=blue]
                              > e.g.[/color]

                              Very much "e.g.", indeed.
                              [color=blue]
                              > echo "<html><body><h ead>";
                              > echo "<script LANGUAGE=\"Java Script1.4\" type=\"text/javascript\"">;
                              > echo "function sayHello(){";
                              > echo "alert(\"hello\ ");";
                              > echo "</script></head></body></html>";[/color]

                              Do you have even a single clue about the languages you are using?

                              1. The above is as inefficient in PHP as it can be. PHP is the
                              PHP Hypertext *Preprocessor*. What is not within `<?php ... ?>'
                              (or `<? ... ?>' with short_open_tag= on) is not parsed by PHP
                              but simply thrown to stdout, i.e. raw data to be transferred to
                              the client by the Web server if used in a CGI environment.

                              2. The above will not generate Valid HTML, since
                              - the DOCTYPE declaration is missing
                              - the `body' element must not contain the `head' element
                              - the `title' element is missing.

                              see <http://validator.w3.or g/>.
                              This will force the User Agent to use Quirks Mode, if available,
                              and so produce unreliable results.

                              3. The `language' attribute is deprecated in HTML 4 and XHTML 1, and
                              the attribute value you are using is, at the most, not fitted for
                              the task.

                              Correction
                              -----------

                              Optionally before:

                              <?php
                              ...
                              ?>

                              Mandatory regarding the task:

                              <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
                              "http://www.w3.org/TR/strict.dtd">
                              <html>
                              <head>
                              <title>JavaScri pt in a PHP script</title>

                              <script type="text/javascript">
                              function sayHello()
                              {
                              alert("hello");
                              }
                              </script>
                              </head>

                              <body>
                              ...
                              </body>
                              </html>

                              Optionally after:

                              <?php
                              ...
                              ?>


                              PointedEars

                              Comment

                              Working...