Reply
SSI and javascript problem
Old 01-05-2008, 05:59 AM SSI and javascript problem
Cepola's Avatar
Novice Talker

Posts: 12
Name: Stefan Petrovic
Location: Rovinj, Croatia
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
 
When You Register, These Ads Go Away!
Old 01-05-2008, 06:05 AM Re: SSI and javascript problem
Truly's Avatar
Extreme Talker

Posts: 225
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, 08:40 AM Re: SSI and javascript problem
maxxximus's Avatar
Extreme Talker

Posts: 206
Name: Rob
Location: UK
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, 02:23 PM Re: SSI and javascript problem
Cepola's Avatar
Novice Talker

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

Posts: 36
Name: Jesus
Delete this?

<input type="radio" name="event" value="advent_prague" onClick="AdventPrague()">
Advent Prag</label>
<div id="additional"></div>
FotoZone is offline
Reply With Quote
View Public Profile Visit FotoZone's homepage!
 
Old 01-05-2008, 04:56 PM Re: SSI and javascript problem
chrishirst's Avatar
Super Moderator

Posts: 15,326
Location: Blackpool. UK
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. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System | Bits & Bobs
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-13-2008, 06:33 AM Re: SSI and javascript problem
Cepola's Avatar
Novice Talker

Posts: 12
Name: Stefan Petrovic
Location: Rovinj, Croatia
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, 11:13 AM Re: SSI and javascript problem
Cepola's Avatar
Novice Talker

Posts: 12
Name: Stefan Petrovic
Location: Rovinj, Croatia
anyone?
Cepola is offline
Reply With Quote
View Public Profile
 
Old 01-15-2008, 11:38 AM Re: SSI and javascript problem
chrishirst's Avatar
Super Moderator

Posts: 15,326
Location: Blackpool. UK
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. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System | Bits & Bobs
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-21-2008, 10:03 PM Re: SSI and javascript problem
carloncho's Avatar
Skilled Talker

Posts: 80
Name: Carlos
I vote for this solution In the original code, you may have problems with codification of html into javascript string.
__________________
-----------------------
http://www.xumby.com
carloncho is offline
Reply With Quote
View Public Profile Visit carloncho's homepage!
 
Reply     « Reply to SSI and javascript problem
 

Thread Tools

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

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


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


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

 


Page generated in 0.15786 seconds with 12 queries