473,800 Members | 2,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I want the contents of a file to be put in a textbox without refreshing

16 New Member
hi guys,
I have a form in html which has the city drop down. when clicking the drop down a javascript is called and a file(test.txt) is created and the city is written into the file.

Through php i want to open the same file(test.txt), fetch the values and display it in a text box without refreshing or reloading the form. Is it possible.

After refreshing it works but i want without refreshing the form.

here is the code.


Expand|Select|Wrap|Line Numbers
  1.  (javascript)
  2. function addToList_city(city) 
  3. {
  4. var c =document.assess_form.cit.value;
  5.  
  6. var fso = new ActiveXObject("Scripting.FileSystemObject");
  7. var s = fso.CreateTextFile("C://test.txt", true);
  8. s.write(c)
  9.  
  10. }

[PHP]$filename = "c://test.txt";
if (file_exists($f ilename)) {

$fp = fopen($filename ,'r');
$citfile= fread($fp, filesize($filen ame));
}
@unlink($filena me);[/PHP]

code: (HTML)
[HTML]<html>
<form name = assess_form.php >
<select name="cit" onchange="addTo List_city(this. form)">
<option value="h"> Haryana </option>
<option value = "c">Chennai </option>
</select>

<input type="text" name="city" value="<? echo $citfile ?>">
</form>
</html>[/HTML]
Mar 25 '08 #1
6 1956
TheServant
1,168 Recognized Expert Top Contributor
php is server side which means: it is only done on page load, which is why it won't do anything until you refresh. What you want is javascript (client side) and have it so when you make a selection it runs a javascript function to change the text box contents. I am no javascript pro, so maybe best asking in the javascript forum.

But yeah, you can't do that in php.
Mar 25 '08 #2
gamernaveen
28 New Member
Well actually you can. There comes AJAX.
It cannot be done without refreshing though but it can be done without refreshing the whole page. There are ajax functions to get data from server without refreshing the whole page. Check the AJAX forum.
Mar 25 '08 #3
ronverdonk
4,258 Recognized Expert Specialist
Have a look at the tutorial and demo here Dynamically loaded articles . That will tech and show you how to load pieces of text from the server and update part of the screen dynamically.

Also have a look at THIS article by Iam Clint in the JavaScript articles section at this site.
Ronald
Mar 25 '08 #4
TheServant
1,168 Recognized Expert Top Contributor
Yes, AJAX can solve it. Great tutes btw. I should really learn AJAX sometime.
Mar 25 '08 #5
arggg
91 New Member
Well actually you can. There comes AJAX.
It cannot be done without refreshing though but it can be done without refreshing the whole page. There are ajax functions to get data from server without refreshing the whole page. Check the AJAX forum.
AJAX isn't PHP it is Javascript which is basically what the post above you was saying.
Mar 25 '08 #6
TheServant
1,168 Recognized Expert Top Contributor
AJAX isn't PHP it is Javascript which is basically what the post above you was saying.
Yes! So no php, but this can be solved in AJAX. I recommend asking in the AJAX forum if you have more questions.
Mar 25 '08 #7

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

Similar topics

3
2488
by: GraVity via DotNetMonster.com | last post by:
Hello all I am new to asp.net or web programming I have a requirement, I have to submit a document to another server using my webpage, there is a perticular protocol for doing that. This protocol requires to make many requests between the servers for the submission of single document, as the result the webpage refreshes many time(for each request between the servers). I want that some how my webpage doesn't refresh and at the same time...
2
2546
by: jdi | last post by:
Hello, I have a seemingly basic question about ASP.NET. I would like to create a page containing an image, which keeps swapping the url of the image source, without refreshing the entire page. So when the page first loads I'd like the image url to be "img1.gif"; then 20 seconds later "img2.gif"; then "img3.gif", and so on. All this should take place dynamically without refreshing the page. Any help would be appreciated.
3
1847
by: Aitham alama | last post by:
Hi There, My question is as following, I have a webform (Webform1) which contains one label control and command button, when the user clicks the button another webform (Webform2) appears, webform2 contains only one control which is the Calendar control, I want to do the following 1- when the user selects a date from the webform2, I want the value
2
2486
by: Ben | last post by:
Hi, One ASP.NET transactional page conducts a long transaction in a button click function. I want to display the transaction progress info in label control without refreshing page. It is because page refreshing will commit the transaction automatically. How to do it?
3
8729
by: user | last post by:
Hi, let's say a page loads on a browser. Without refreshing the page, multiple textboxes within the page gets real time data @ a few seconds interval. what is the logic behind to achieve this? pls advise.
13
7458
by: honey99 | last post by:
Hi! I have to fix a problem in JSP.Actually,i have a JSP page say Ex1.jsp.In this Ex1.jsp i have an anchor tag which links into another JSP page i.e when i click on the link another pop-up window will open.My problem is the pop-up window and the parent window has same combobox.if i add data through html form in pop-up window(Ex2.jsp) it enters the combobox...but the data in the combobox of parent window(Ex1.jsp) is entering only when i refresh...
1
1045
by: shankari07 | last post by:
hi guys, I have a form in html which has the city drop down. when clicking the drop down a javascript is called and a file(test.txt) is created and the city is written into the file. Through php i want to open the same file(test.txt), fetch the values and display it in a text box without refreshing or reloading the form. Is it possible. After refreshing it works but i want without refreshing the form. here is the code.
3
4166
by: manuitpro | last post by:
Hi All, I have page with many tabs, in one of the tab i have a form (only a input box) and i want to show some output on the same tab view based on the user input. (bvy using php function) I dont want to refresh the page becuase other tabs already has some outputs that i dont want to touch. I know ajax is a solution for this, but i have gone through many ajax examples, it passes values to another page (.php). I dont want to do this...
1
2186
by: adige | last post by:
Hi. I would like to automatically fill in the textbox labeled "Amount 2" after choosing the value of Amount without refreshing the page. I guess it requires javascript or AJAX but i don't know how to do it. Any help please? (Btw, it's wordpress) http://i55.tinypic.com/29crpdz.jpg $options_amount = array("0","1","2","3","4","5","6","7","8","9","10+"); $metabox = array();
0
9691
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
9551
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
10507
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10036
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
7582
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
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
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

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.