473,320 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Drop-down list from text file

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:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>XMLHttpRequest Object GET Request</title>
  4. </head>
  5. <body>
  6.  
  7. <script language="javascript" type="text/javascript">
  8. <!--
  9.  
  10.   // request variable
  11.   var request_var;
  12.  
  13.   // Request object method wrapper function
  14.   function request_object()
  15.   {
  16.     try
  17.     {
  18.       return new ActiveXObject('Msxml2.XMLHTTP');
  19.     }
  20.       catch(e)
  21.       {
  22.         try
  23.         {
  24.         return new ActiveXObject('Microsoft.XMLHTTP');
  25.         }
  26.           catch(e)
  27.           {
  28.           return new XMLHttpRequest();
  29.           }
  30.       }
  31.   }
  32.  
  33.   // Call the request object method wrapper function
  34.   request_var=request_object();
  35.  
  36.   if(!request_var)
  37.   {
  38.     alert("Your Web browser does not support the XMLHttpRequest object.");
  39.   }
  40.  
  41.   function load()
  42.   {
  43.     if(request_var.readyState==4)
  44.     {
  45.     document.getElementById('elements_id').innerHTML=request_var.responseText;
  46.     }
  47.   }
  48.  
  49.   function call()
  50.   {
  51.     if(request_var)
  52.     {
  53.     d=document;
  54.     request_var.open("GET","textfile.txt",true);
  55.     request_var.onreadystatechange=load;
  56.     request_var.send(null);
  57.     }
  58.   }
  59.  
  60. //-->
  61. </script>
  62.  
  63. <div id="elements_id"></div> 
  64.  
  65. <a onclick="call()" href="#">XnMLHttpRequest Object GET Request</a>
  66. </body>
  67. </html>
  68.  
  69.  
Aug 3 '06 #1
1 4749
acoder
16,027 Expert Mod 8TB
The changes that are required are:
1. parse the response instead of writing it to the screen. The response is a string. Split it into an array using the split() method.
2. Loop over the array to add the options. You can use the options array (and new Option()) or the select object's add() method to add options.
May 5 '08 #2

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

Similar topics

1
by: Sabrina | last post by:
Hi everybody, I need some help in SQL Server. I am looking for a command that will "Drop all user table" in a user database. Can anyone help me? Thank you very much Sabrina
2
by: James Knowlton | last post by:
Hello, I'm just returning to MS SQL Server after two years of dealing with Sybase ASE. I need to drop a column, using the alter table command. I keep getting an error indicating that a...
2
by: Ryan | last post by:
Just a quicky about temporarary tables. If using QA, when you create a temporary table, it gets dropped if you close the query. Otherwise you need to state 'DROP TABLE myTable' so that you can...
1
by: Ian Dobson | last post by:
Hi, I need to drop a schema from a database but it has 400 tables in it. Is there an easy way to do it other than drop table schema1.table1 drop table schema1.table2 etc.. to 400 and then drop...
10
by: BuddhaBuddy | last post by:
Platform is DB2/NT 7.2.9 The table was created like this: CREATE TABLE MYTEST ( MYTESTOID bigint not null primary key, FK_OTHEROID bigint not null references other, FK_ANOTHEROID bigint not...
8
by: WindAndWaves | last post by:
Hi everyone, Has anyone got any experience with drop and drag in Access? I would like to make a calendar style form where my users can drop and drag appointments.... I am using Access 2003...
5
by: Markus | last post by:
I tried this: ALTER TABLE Dokumente DROP COLUMN docPrioID but I get this errormessage: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: COLUMN;ABLE Dokumente DROP;CONSTRAINT
0
by: RHSFSS | last post by:
Hi, I have a Drag and Drop registration problem (See http://www.thescripts.com/forum/thread434707.html for similar problem post), can anyone out thereadvise on the best solution? I have a .NET 2.0 ...
15
by: uwcssa | last post by:
I try to drop a table as: I got: During SQL processing it returned: SQL0478N The object type "TABLE" cannot be dropped because there is an object "sch.SQL070515104729271", of type "FUNCTION",...
5
by: sreemati | last post by:
Hi I am working on SQL SERVER 200 and I am trying to drop the default constraints set in few tables. I tired to follow the instructions given in MSDN for dropping a default: 1) Unbind the code...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.