473,406 Members | 2,259 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,406 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 4754
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.