Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Using php include inside javascript innerhtml
Old 07-01-2010, 10:32 AM Using php include inside javascript innerhtml
Experienced Talker

Posts: 31
Trades: 0
Hello, I am having an issue with using javascript innerhtml. I am making a page which changes a divs content when someone clicks a button. I tried using php to include the file when the button is clicked and it dosent do anything... I dont know much about javascript so I'd appreciate any help!

Here's my code.

HTML Code:
<html>
<head>
<script language="javascript">

function viewTest() {

document.getElementById("other").innerText = "<br /> <?php include 'test.php'; ?>";
}

function viewTest2() {

document.getElementById("other").innerHTML = "<br /> <?php include 'test.php'; ?>";
}

</script>

</head>

<body>
    <div id="centerbody">
        <div id="smallwebsitename" onclick="viewTest();">Link One</div>
        <div id="smallwebsitename" onclick="viewTest2();">Link Two</div>
    </div>
    <div id="other">
    
    </div>

</body>
</html>
And heres the code from test.php

PHP Code:
<?php
    
include 'databasesettings.php';

    
$result mysql_query("SELECT * FROM #### WHERE ##"
    or die(
mysql_error()); 

?>
    <table id="updates">
    <td colspan="5" align="center" id="none">DATES</td>
    <tr id="tablehead">
    <td>Date</td>
    </tr>
<?php while($row mysql_fetch_array$result )) { ?>
    <tr id="update">
    <td align="center"><?php echo $id $row['date']; ?></td>                             
    </tr></a>
<?php ?>

</table>
Thanks for any help!

-Dillon
Dillon is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-01-2010, 10:38 AM Re: Using php include inside javascript innerhtml
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It won't work!


PHP runs on the server and is finished with before javascript even starts.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-01-2010, 10:49 AM Re: Using php include inside javascript innerhtml
Experienced Talker

Posts: 31
Trades: 0
Oh ok, Is there a different way that I could do this then?

-Dillon
Dillon is offline
Reply With Quote
View Public Profile
 
Old 07-01-2010, 10:57 AM Re: Using php include inside javascript innerhtml
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Use AJAX methods
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-01-2010, 11:11 AM Re: Using php include inside javascript innerhtml
Experienced Talker

Posts: 31
Trades: 0
Awesome! That worked Thanks alot!

-Dillon
Dillon is offline
Reply With Quote
View Public Profile
 
Old 07-01-2010, 04:34 PM Re: Using php include inside javascript innerhtml
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
good job. You figured out your first AJAX problem in under 15 minutes. Much better than many of the people who are learning around here.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Using php include inside javascript innerhtml
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16500 seconds with 12 queries