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
SSI and javascript problem
Old 01-05-2008, 04:59 AM SSI and javascript problem
Cepola's Avatar
Novice Talker

Posts: 12
Name: Stefan Petrovic
Location: Rovinj, Croatia
Trades: 0
Hi folks, i'm new on the forum and this is my first post (who cares?) Well, i'm also new to php and all that stuff, so i've encountered a problem which i think isn't so problematic after all. I didn't know whether to post this thread in the javascript forum or here, but i thought that the actual problem lays in php.
What i was trying to do is the following: a html form with some radio buttons and a second part which depended through a javascript to every single button an which should appear when triggered by the onClick function.
Here is just one case, in order that you understand the whole thing:
HTML Code:
<head>
      <script type="text/javascript">
function AdventPrague()
{
document.getElementById("additional").innerHTML="<?php include(event_forms/advent_prague.htm); ?>";
}
      </script>
        <script type="text/javascript">
</head>
<body>
<label>
<input type="radio" name="event" value="advent_prague" onClick="AdventPrague()">
Advent Prag</label>
<div id="additional"></div>
Everything works when I directly insert HTML through the javascript but it would overload the file size, so i'd like single files to load on every onClick, but the PHP include won't work, as i suppose the server isn' triggered. Can you help please?

PS the whole form is here http://www.musicandfriends.com.hr/form.php

Cepola is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-05-2008, 05:05 AM Re: SSI and javascript problem
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
I am pretty sure you will need to use AJAX/HttpRequest but thats my next thing to learn so I unfortunately cant give you any specifics.
Truly is offline
Reply With Quote
View Public Profile
 
Old 01-05-2008, 07:40 AM Re: SSI and javascript problem
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Yes this is a Js problem.

As mentioned by Truly this would be best done using the Http request object.

The script below will work.Just pass the requested page (event_forms/advent_prague.htm in this case) as an argument in the AdventPrague function.

HTML Code:
<head>
      <script type="text/javascript">
function AdventPrague(a)
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
       document.getElementById('additional').innerHTML=xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET",a,true);
    xmlHttp.send(null);
  }

   </script>
</head>
<body>
<label>
<input type="radio" name="event" value="advent_prague" onClick="AdventPrague('event_forms/advent_prague.htm')">
Advent Prag</label>
<div id="additional"></div>
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 01-05-2008, 01:23 PM Re: SSI and javascript problem
Cepola's Avatar
Novice Talker

Posts: 12
Name: Stefan Petrovic
Location: Rovinj, Croatia
Trades: 0
Thanks maxxximus, this helped!
Cepola is offline
Reply With Quote
View Public Profile
 
Old 01-05-2008, 03:31 PM Re: SSI and javascript problem
FotoZone's Avatar
Experienced Talker

Posts: 36
Name: Jesus
Trades: 0
Delete this?

<input type="radio" name="event" value="advent_prague" onClick="AdventPrague()">
Advent Prag</label>
<div id="additional"></div>
__________________
Forum
Please login or register to view this content. Registration is FREE
Free
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

FotoZone is offline
Reply With Quote
View Public Profile Visit FotoZone's homepage!
 
Old 01-05-2008, 03:56 PM Re: SSI and javascript problem
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
but the PHP include won't work, as i suppose the server isn' triggered
Nope.
You cannot use a client side script to insert server side php.
Server side code runs and ends before the page is even sent to the client and javascript code starts to run.
__________________
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 online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-13-2008, 05:33 AM Re: SSI and javascript problem
Cepola's Avatar
Novice Talker

Posts: 12
Name: Stefan Petrovic
Location: Rovinj, Croatia
Trades: 0
Well, now I'd like to know if it's possible to include the AJAX stuff in a variable as i have many functions in which i'd like to reuse it. Tanks in advance!
Cepola is offline
Reply With Quote
View Public Profile
 
Old 01-15-2008, 10:13 AM Re: SSI and javascript problem
Cepola's Avatar
Novice Talker

Posts: 12
Name: Stefan Petrovic
Location: Rovinj, Croatia
Trades: 0
anyone?
Cepola is offline
Reply With Quote
View Public Profile
 
Old 01-15-2008, 10:38 AM Re: SSI and javascript problem
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I would guess we are not sure what you mean by;
Quote:
Well, now I'd like to know if it's possible to include the AJAX stuff in a variable as i have many functions in which i'd like to reuse it.
__________________
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 online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-21-2008, 09:03 PM Re: SSI and javascript problem
carloncho's Avatar
Skilled Talker

Posts: 80
Name: Carlos
Trades: 0
I vote for this solution In the original code, you may have problems with codification of html into javascript string.
__________________
-----------------------

Please login or register to view this content. Registration is FREE
carloncho is offline
Reply With Quote
View Public Profile Visit carloncho's homepage!
 
Reply     « Reply to SSI and javascript problem
 

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.70253 seconds with 12 queries