473,804 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem while calling two pages which includes Js pages

254 Contributor
Hi

I am calling two pages using Ajax Get_Pages.php and Get_Content.php from combo box. Both pages are displayed based on selection from combo box.

Main problem is that it is not showing the editor which is called on the Get_Content.php . in Main Page.

I have included the js files in the head section.

all the files are on the same directory.

But when I am running the Get_Content.php it is showing the Editors so what is the problem

Please help me out.

I have given the codes for the pages.
Main Page which is calling the JS Page.
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <script src="Get_Page.js" type="text/javascript"></script>
  3. </head>
  4. <body>
  5. <form action="insertimage.php" method="post" enctype="multipart/form-data">
  6. <table><tr>
  7.  <td valign="middle">Page Type</td>
  8.             <td align="left" valign="bottom"><select name="Page_Type" onchange="getPage(this.value)">
  9.               <option>--Select One--</option>
  10.               <option value="image">Image</option>
  11.               <option value="content">Text</option>
  12. </td></tr>></table>
  13. </form>
  14. </body>

Expand|Select|Wrap|Line Numbers
  1. //js page
  2.  
  3. var xmlHttp
  4. function getPage(str)
  5.  
  6.     xmlHttp=GetXmlHttpObject()
  7.     if (xmlHttp==null)
  8.      {
  9.          alert ("Browser does not support HTTP Request");
  10.          return;
  11.      }
  12.      var image="image";
  13.     if(str==image)
  14.     {
  15.     var url="Get_Page.php";
  16.     url=url+"?q="+str;
  17.     url=url+"&sid="+Math.random();
  18.     xmlHttp.onreadystatechange=stateChanged ;
  19.     xmlHttp.open("GET",url,true);
  20.     xmlHttp.send(null);
  21.     }
  22.     else
  23.     {
  24.     var url="Get_Content.php";
  25.     url=url+"?q="+str;
  26.     url=url+"&sid="+Math.random();
  27.     xmlHttp.onreadystatechange=stateChanged ;
  28.     xmlHttp.open("GET",url,true);
  29.     xmlHttp.send(null);
  30.     }
  31.  
  32. }
  33. function stateChanged() 
  34.     if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  35.      { 
  36.          document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
  37.      } 
  38. }
  39. function GetXmlHttpObject()
  40. {
  41.     var xmlHttp=null;
  42.     try
  43.      {
  44.          xmlHttp=new XMLHttpRequest();
  45.      }
  46.     catch (e)
  47.      {
  48.          try
  49.           {
  50.               xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  51.           }
  52.          catch (e)
  53.           {
  54.               xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  55.           }
  56.       }
  57.     return xmlHttp;
  58. }
  59.  
Expand|Select|Wrap|Line Numbers
  1. //Get_Page.php
  2. <table>
  3. <tr valign="bottom">
  4.         <td width="20%" align="left" valign="middle">Caption1</td>
  5.         <td width="17%" align="left" valign="middle"><input name="Image_Name1" type="text" id="Image_Name" value="" size="15" /></td>
  6.         <td width="18%" align="center" valign="middle">File1: </td>
  7.         <td width="45%" align="left" valign="middle"><input name="File1" type="file" id="File1" value="" size="15" /></td>
  8.       </tr>
  9. <tr>
  10.         <td height="26" align="left" valign="middle">&nbsp;</td>
  11.         <td height="26" colspan="2" align="left" valign="bottom"><input type="submit" name="Upload" value="Upload"/>
  12.             <input type="reset" name="Reset" /></td>
  13.       </tr>
  14. </table>
  15.  
Expand|Select|Wrap|Line Numbers
  1. //Get_Content.php
  2.  
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <script language="javascript" src="wysiwyg.js"></script>
  6. <title>Untitled Document</title>
  7. </head>
  8. <body>
  9.  
  10.     <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
  11.       <tr align="left">
  12.         <td width="14%" align="left" valign="middle">&nbsp;&nbsp;&nbsp;&nbsp;Content Id </td>
  13.         <td width="86%" valign="middle"><input type="text" name="Content_Id" value="" /></td>
  14.       </tr>
  15.       <tr align="left">
  16.         <td align="center" valign="middle">Content Name </td>
  17.         <td valign="middle"><input type="text" name="Content_Name" value="" /></td>
  18.       </tr>
  19.       <tr align="left">
  20.         <td align="left" valign="top">&nbsp;&nbsp;Description</td>
  21.         <td valign="middle"><textarea id="textarea2" name="Content_Description" style="height: 200px; width: 500px;">
  22.  
  23.           </textarea>
  24.              <script language="javascript1.2">
  25.                   generate_wysiwyg('textarea2');
  26.             </script> </td>
  27.       </tr>
  28.       <tr align="left">
  29.         <td valign="middle">&nbsp;</td>
  30.         <td valign="middle"><input type="submit" name="Content" value="Add Content" />
  31.           <input name="reset" type="reset" /></td>
  32.       </tr>
  33. </table>
  34. </body>
  35. // end of page.
Now Problem is that code works fine but it is not showing the editor which is included through wysiwyg.js when I am calling it from main page.

But when I am running the Get_Content.php it shows the editor.

so is there any thing that I can not call Series of Js pages. If it is then how can I do it.
Dec 18 '07
47 3302
acoder
16,027 Recognized Expert Moderator MVP
In addition to that, if it's a simple HTML file, you could just use JavaScript to add that content dynamically without the need for Ajax.

I can see where your problem is, though. You've defined GetXmlHttpObjec t twice. You only need it once. Secondly, you've already declared the global variable xmlhttp in file.js. Thirdly, you've redefined stateChanged(). Change that to something else in fileabc.js and change line 13 to reflect that.
Jun 17 '09 #41
mukeshrasm
254 Contributor
@acoder
Thanks again! I fixed the errors now why I need to define GetXmlHttpObjec t once only and what problem stateChanged() caused in fileabc.js. and finally cann't I define global variables twice.

I am not calling html file actually it is dynamic file. that's why I am using ajax.

Thanks again!
Jun 19 '09 #42
acoder
16,027 Recognized Expert Moderator MVP
Although it may not necessarily result in errors, it's bad practice to define the same function twice. In your case, stateChanged was different, so was the main cause of the problem. If you can, try to avoid global variables or keep to a minimum - see this.
Jun 19 '09 #43
mukeshrasm
254 Contributor
@acoder
thanks! and useful link to learn if you have some more please refer me.
Jun 20 '09 #44
acoder
16,027 Recognized Expert Moderator MVP
See the Off-site links sticky for some useful JavaScript links if you haven't already done so.
Jun 20 '09 #45
mukeshrasm
254 Contributor
@acoder
Hi I want to give reference to some thread of this posting to php forum of this site how could I do this
Jun 23 '09 #46
acoder
16,027 Recognized Expert Moderator MVP
You mean you want to refer/link to this thread? Just copy the URL in the address bar.
Jun 23 '09 #47
mukeshrasm
254 Contributor
@acoder
ok thanks! actually I wanted to refer this thread to some of css and php topic of this site so for that I asked that how I will refer it to others.
Jun 23 '09 #48

Sign in to post your reply or Sign up for a free account.

Similar topics

31
3852
by: Bruce W...1 | last post by:
This is a best practices question. For a website where PHP is used, does it make sense to have both .htm and .php files? In other words, for pages that have no active content there's no point in naming them with a .php extension. Is there any advantage or disadvantage to making all files .php, or the same for mixing them with .htm files? What do you do, and why?
6
2727
by: Rob Long | last post by:
Hey, I've written a custom HTML library using many PHP scripts as seperate files (just like I'd do a java project) and I'm having some problems where I'm including scripts in different directories from already included scripts... basically where there'a an include chain spanning multiple directories. I've reduced the problem to its core:
3
1385
by: Keith | last post by:
I have a block of ASP code (enclosed in <% .. %>). How can I call that piece of code from another piece of similar code? And can the code be in any order on the page for it to work? Thanks
4
1572
by: Chad Richardson | last post by:
As I'm writing this I think I am answering my own question, but I'd like to get any other ideas on the subject as well. I have a standard Header.asp that I want to include in every other page in my site. Header.asp is located in the root folder, but the calling pages are in various folders/levels. Since the relative paths specified in header are subject to change and are based on the relative path of the calling page, problems arise....
2
4641
by: WisTex | last post by:
I've come across a very weird problem. Virtual includes work on all my ASP pages on the entire website, including those in subdirectories, yet they won't work on a particular page I created, even though the virtual include statement is copy & pasted exactly as it appears on the working pages. What would cause virtual includes to work in one page on a website, but not on another? Error Message: Microsoft VBScript runtime error...
78
4984
by: Josiah Manson | last post by:
I found that I was repeating the same couple of lines over and over in a function and decided to split those lines into a nested function after copying one too many minor changes all over. The only problem is that my little helper function doesn't work! It claims that a variable doesn't exist. If I move the variable declaration, it finds the variable, but can't change it. Declaring the variable global in the nested function doesn't work...
8
1734
by: supasnail | last post by:
I have a happily working set of asp pages which read from the database via include file "./_private/include/database.mdb". However, when I try to gain access to this database on pages one folder removed using "../_private/include/database.mdb", the pages won't display. This whole system works fine on my home test server (iis.5.0), but 'breaks' when uploaded to the public server. I know the path to database is correct because the upper...
12
8466
by: Atlas | last post by:
I'm working on a multilanguage ASP/HTML site using a IIS6 web server. It perfectly works with two languages (english and italian) in this way: - basically the same ASP code for every language - language-specific content is stored in text files, every language has it's own directory contents. - to enhance usability and formatting the language-specific contents are stored with html syntax; basically the code that normally stands between...
17
1918
by: henry | last post by:
Folks Here's a skeleton, generic HTML page, call it "index.php". You'll see a bit of php code in the middle: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head>
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10096
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.