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
- (javascript)
- function addToList_city(city)
- {
- var c =document.assess_form.cit.value;
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var s = fso.CreateTextFile("C://test.txt", true);
- s.write(c)
- }
[PHP]$filename = "c://test.txt";
if (file_exists($filename)) {
$fp = fopen($filename,'r');
$citfile= fread($fp, filesize($filename));
}
@unlink($filename);[/PHP]
code: (HTML)
[HTML]<html>
<form name = assess_form.php>
<select name="cit" onchange="addToList_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]