www.webdeveloper.com
Results 1 to 4 of 4

Thread: how to populate a list box with the file content dynamically?

Hybrid View

  1. #1
    Join Date
    Mar 2013
    Posts
    6

    how to populate a list box with the file content dynamically?

    i want to populate a html list box (select tag) with the content of file (i.e each line of the file should become a single option in the list box (select element)).

    suppose i have a file say
    Code:
    "load_lines.txt"
    containing

    Code:
    s1.txt
    s2.txt
    s3.txt
    s4.txt
    s5.txt
    there is a html form

    Code:
    <html>
      <head>
        <title>List box Loading</title>
      </head>
    
      <body>
        <form id="frm1" name="frm1" action="" method="GET">
    
          <select id="lb" name="lb" size="5">
          </select><br /><br />
    
          <input type="button" id="btn1" name="btn1" value="OK" />
    
        </form>
      </body>
    </html>
    when the form is loaded it should populate the list box (select element) with the contents of the file
    Code:
    "load_lines.txt"
    .

    can anyone tell how to do this using javascript?. please give the javascript code.

  2. #2
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    Sorry no one replied to your thread. to be honest I am a little confused on what you are asking exactly. You want a box to populate a list of links that all are stored in a file?

    or your saying you want a box to be on the screen and when someone clicks the button it populates the list of items in a list format?

    try to be a little more clear and I would be more than happy to help you.

    Whats your main objective here, be more descriptive, and why are you referring to javascript? Are you assuming you have to use it or are you wanting to know how to complete the task with javascript just for the sake of it?

  3. #3
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293

  4. #4
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    This would be very easy with php...
    you could make each line of text a variable and then when you click the button in the form it could populate a list calling on each variable. or you could do this with ajax. if you wanted to get fancy with it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles