Advanced Search

Page 3 of 3 FirstFirst 123
Results 21 to 22 of 22

Thread: Passing php variable as Javascript argument

  1. #21
    Join Date
    Mar 2011
    Location
    N 11° 19' 0.0012 E 142° 15' 0
    Posts
    1,421
    Thanks
    37
    Thanked 84 Times in 83 Posts
    Blog Entries
    3

    Default

    I'm glad you figured it out zomb1e...

    Remember -

    If this thread is finished, please set it to resolved.
    You can do this by editing the first post within the thread - Pressing go advanced - Then where it says no prefix, selecting resolved then save.
    keebs - keyboard1333 [at] gmail [dot] com
    Anime Views Forums

  2. #22
    Join Date
    Nov 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hey, I'm sorry to bump this old thread, but this is the only thread I've found in hours of searching that has actually given me the answers I've needed, but when I run my code (I'll link it below) the output that I get is <?php echo $a ?> and then <?php echo $c ?> in another alert window... I'm extremely miffed why this is happening.. Here's muh code :

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    
    <?php 
    $a = 'Fatber Christmas'; 
    $b = '27 Sunshine Street /n America'; 
    $c = nl2br($b); 
    ?>
    
    <html>
    
    <head>      
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    		<meta name="description" content="Kenneth So - Automotive and Nightclub Photography">
    		<meta name="keywords" content="automotive photography, car photography, nightclub photography, rave photography, club photography, edm photography, car pictures, car images, automotive, cars, nightclub, rave, edm, photographs, digital photography">
    		<meta name="abstract" content="Kenneth So - Automotive and night club photography.">
    		<meta name="robots" content="index,follow">
    		<meta name="resource-type" content="document">
    		<meta name="revisit-after" content="5 days">
        <title>Kenneth So Photography</title>
        <link rel="stylesheet" href="kennethsostylesheet.css" type="text/css">
        <link rel="shortcut icon" href="Photos/favicon.png" type="image/png">
        
        <script type="text/javascript"> 
        function test(a,b) { 
        alert(a); 
        alert(b); 
    } 
        </script>
    
        <script type="text/javascript" src="picScript.js"></script>
    </head>
    
    <body>
        
        <a onClick="test('<?php echo $a ?>', '<?php echo $c ?>');">LINK</a> 
       
    
    
        <div id="headerBar">
            <div id="logo">
                <a href="javascript:void(0)" ><img src="Photos/FinalizedLogo.png" alt="logo" height="100px" width="400px" onclick="setNum(1)"></a> 
            </div>
            <div id="titleBar">
                <p>
                <a href="javascript:void(0)" onclick="setNum(1)">Home</a> |
                <a href="javascript:void(0)" onclick="setNum(2)">Automotive</a> |
                <a href="javascript:void(0)" onclick="setNum(3)">Nightlife</a> |
                <a href="/about.html">About Me</a> |
                <a href="/contact.html">Contact</a>
                </p>
            </div>
        </div>
        <div id="imageBox">
            <div id="imageView">
            </div>
            
            <div id="imagePreview">
            </div>
        </div>
    </body>
    </html>
    setNum(); is a function in the picScript.js file. TIA!!! (and sorry for bumping the old thread but it's exactly what I needed)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •