Hi
I need to make script that creates drop-down list from text file (new line in text file – new line in drop-down list). Somebody told me that I should use Ajax and XMLHttpRequest for that, so I have found on internet script that can write content from text file on screen, but I don’t know how to modify it to write it in drop-down list.
How to add reference.value to make values for drop-down?
This is it:
I need to make script that creates drop-down list from text file (new line in text file – new line in drop-down list). Somebody told me that I should use Ajax and XMLHttpRequest for that, so I have found on internet script that can write content from text file on screen, but I don’t know how to modify it to write it in drop-down list.
How to add reference.value to make values for drop-down?
This is it:
Code:
<html> <head> <title>XMLHttpRequest Object GET Request</title> </head> <body> <script language="javascript" type="text/javascript"> <!-- // request variable var request_var; // Request object method wrapper function function request_object() { try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { return new XMLHttpRequest(); } } } // Call the request object method wrapper function request_var=request_object(); if(!request_var) { alert("Your Web browser does not support the XMLHttpRequest object."); } function load() { if(request_var.readyState==4) { document.getElementById('elements_id').innerHTML=request_var.responseText; } } function call() { if(request_var) { d=document; request_var.open("GET","textfile.txt",true); request_var.onreadystatechange=load; request_var.send(null); } } //--> </script> <div id="elements_id"></div> <a onclick="call()" href="#">XnMLHttpRequest Object GET Request</a> </body> </html>
Comment