Jump to content

khadra4ever

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

khadra4ever's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi guys! I have a form with a button and a textarea, when i click on the button it opens a text file and displays its content in the textarea the problem is when i update the file and click the button the changes i made to the file don't show in the textarea, it only shows the old content. here's my code <script type="text/javascript"> var req; var FileName="http://localhost/file.txt"; function OpenFile(url) { req = false; // branch for native XMLHttpRequest object if(window.XMLHttpRequest && !(window.ActiveXObject)) { try { req = new XMLHttpRequest(); } catch(e) { req = false; } // branch for IE/Windows ActiveX version } else if(window.ActiveXObject) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { req = false; } } } if(req) { req.onreadystatechange = processReqChange; req.open("GET", url, true);; req.send(""); } } function processReqChange() { // only if req shows "loaded" if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('txtOutput').value=req.responseText; } else { alert("There was a problem retrieving the XML data:\n" + req.statusText); } } } </script> <input type="button" id="btnOpen" value="Open File" onClick="OpenFile(FileName)" /><br /> <textarea id='txtOutput' rows='20' cols='100'></textarea> //----------------------------------------------End code-------------------------------------------------------------------------- Can anybody tell me if anything wrong in my code Thanks in advance
  2. Thank you guys for your replies actually i don't know how to use cookies but i used text file instead i don't know if it's a good idea but it worked for me what i did is i had php to write data from database and write the results in a temporary text file then javascript reads that data into array, so it can populate a combobox. once again thank you guys!
  3. Sorry guys i'm not done yet what i'm trying to do now is access that same php variable ($php_var) from an external js file which contains all my javascript code thanks!
  4. Thank you guys for your replies QuickOldCar your solution worked fine thanks alot
  5. Hi everybody! I am new to php, I'm trying to read a php variable using javascript function my code is as follow: <?php $php_var = 100; ?> <SCRIPT type="text/javascript"> var js_var = "<?php =$php_var; ?>"; function display_var() { alert(js_var); } </SCRIPT> <body onload="display_var()"> .......... .......... </body> the problem is that the line alert(js_var); gives me "<?php =$php_var; ?>" instead of 100. I don't know what I'm missing. any help would be greatly appreciated. Thanks in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.