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.
Code: ( php )
[PHP]$filename = "c://test.txt";
if (file_exists($f ilename)) {
$fp = fopen($filename ,'r');
$citfile= fread($fp, filesize($filen ame));
}
@unlink($filena me);[/PHP]
)
[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]
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.
Code:
Code: ( text ) (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) }
Code: ( php )
[PHP]$filename = "c://test.txt";
if (file_exists($f ilename)) {
$fp = fopen($filename ,'r');
$citfile= fread($fp, filesize($filen ame));
}
@unlink($filena me);[/PHP]
)
[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]
Comment