Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Feb 2013
    Location
    Bangor, Maine
    Posts
    12
    Member #
    35395
    <div id="calendar2"><?php include(?><script type="text/javascript">calendar()</script><?php )?></div>

    I have the above code. The variable "calendar()" is being passed to div calendar2.
    I want to incorporate the javascript variable inside an "include" statement.
    I know my syntax is wrong but have tried every variation I can think of to no avail.
    Can anyone help.

    Thank you

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,723
    Member #
    5580
    Liked
    718 times
    What you're saying doesn't really make sense. You can use PHP to output (or echo) javascripting. In your case, there is no need for "include". To "include" something means to include another PHP file or PHP script.

    This is really what you're doing ... but PHP is really not doing anything and isn't required here:

    This:

    <div id="calendar2">
    <?php
    echo "<script type=\"text/javascript\">calendar()</script>";
    ?>
    </div>


    Is the same as:

    <div id="calendar2">
    <script type="text/javascript">calendar()</script>
    </div>


  4. #3
    Junior Member
    Join Date
    Feb 2013
    Location
    Bangor, Maine
    Posts
    12
    Member #
    35395
    I think I understand what you are saying. The thing I do not understand is that the javascript variable in calendar() is a filename I create with a formula ie., 201302.php based on current month and year, and I want to "include" that file at the point where the "calendar2" division is located on my page. I tried what you show above but there is no "include" function so it just echoes the variable name "201302.php" to the screen and does not insert that file into the division.

  5. #4
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    Not going to

    JavaScript that is running on a persons computer is NOT going to execute a PHP file located on a server.

    JavaScript runs on the persons computer AFTER the page is completely sent to the browser. PHP is executed and rendered on the server BEFORE it is sent to the browser.

    Without seeing all the code... I'm just guessing, but I suspect it cannot be done the way you are trying because of the limitations and timing between the 2.

    You either need to generate the JavaScript with the variables in the JavaScript before its sent to the browser( in the PHP code that generates the page ), or you have to do everything you're talking about in JavaScript.

  6. #5
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,723
    Member #
    5580
    Liked
    718 times
    Think of it like this ....

    When you view a web page, everything you see when you look at the HTML source can be created/generated by PHP. That includes all javascripting. PHP then sends the entire HTML source to the user's browser.

    PHP therefore can create whatever javascripting you need, and modify anything in a javascript function. Once the HTML page is sent (echoed) by PHP to the user's browser, the user's browser will execute the javascripting. PHP cannot modify anything at that point.

    So I'm thinking that you're making it harder than it needs to be. I'm just not following what it needs to be. Can you describe it differently and maybe post some scripting/HTML?


  7. #6
    Junior Member
    Join Date
    Feb 2013
    Location
    Bangor, Maine
    Posts
    12
    Member #
    35395
    I just typed a complete response and my browser locked up. damn computers. lol

    here i go again. two files for you to look at:
    www.davidsdomaindesign.com/out/index.php and www.davidsdomaindesign.com/calendars/201302.php

    The calendar() function in javascript in index.php has several functions that all work. The important two include (1) displaying current month/year as February 2013. It displays Prior and Next buttons on the sides of this display. Pressing each button changes the date accordingly. Works perfectly.
    (2) changes the date format to yyyymm and displays 201302.php.

    Hense the other file. As users press next for example (1) changes to march and (2) changes to 03. I was attempting to use include to insert the 201302.php inside my index.php file. all the coding works. its the insert that doesn't.

    each file in the calendars directory is hard coded for that month and year. it displays events going on in the community by geographical area as well as other functions. I'm not sure if i would know how to recode each whole page as a javascript in the index.php file and to switch to every month and year accordingly.

    fell free to look at my work but please do not share it with anyone. eventually it will become www.outinmaine.com which i already reserved.

    i would appreciate any advice you may have. from what you have told me so far, i am going to consider recoding the whole calendar() script to include (no put intended) all my month/year php file information. this sucks.

    thanks again, david


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:35 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com