Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript php and javascripts intermingling

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28080
    thisishard
    Member

    Hi,
    I have at the top of my index.php page the code that links to a .js file. Inside this .js file i need to have a variable which was defined inside my index page but i do not know how to accomplish this.

    Any help appreciated –
    Thanks

    #71239
    islam4hak
    Member

    what about trying to make a display:none element thats contains this variable lets say

    Code:
    $name

    “;
    ?>

    and in the javascript i assume that you use Jquery

    we will select the var div and get the value of it’s content

    Code:
    var Svalue = $(‘#var’).text();

    if this do what you want or dont , please let me know

#71241
islam4hak
Member

second thought i found my first replay was ridiculous

ok lets say thats the header are created with php
so simply you can make this

Code:





Your website title



the only trick here is to defined the variable before the calling the javascript file that you use the variable on it .

i hop you like it.

regards.

#71530
islam4hak
Member

your welcome and you can put your code over here for the second solution
regards.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.