also @ TechSpot: Fair Labor Association begins inspections of Foxconn at Apple's request
Welcome to the TechSpot OpenBoards. Please read the FAQ if you have any questions. Sign up or Login to participate.

Go Back   TechSpot OpenBoards > Software > Software Apps

Collaborate in the cloud with Office, Exchange, SharePoint, and Lync

Javascript for a HTML <select> possible?

Thread Tools Search this Thread
  #1  
Old 09-10-2004
TechSpot Evangelist
 
Location: has left the building
Member since: Aug 2003, 8,165 posts
Javascript for a HTML <select> possible?

Hello Javascript Gurus,

Is there a way to put the following HTML-coding into a Javascript file? (something.JS)

<SELECT NAME="Surname" CLASS="quoteform"><br>
<option selected>Select Surname
<option>Connolly
<option>Gallagher
<option>O'Brien
etc.
</select>

I have a webpage with photos of Family Crests and crested paraphernalia, each of which is only available in the (selectable) Surnames.

Crested items are available in different groups of names. Rather than having the same SELECT code under each photo, I would prefer to call up a Javascript, in which I can stick the complete selection.

Any sample-scripts greatly appreciated.

I searched the WWW intensively, but no samples found.
  #2  
Old 09-10-2004
DigitAlex's Avatar
TechSpot Paladin
 
Location: Brussels, Belgium
Member since: Jul 2002, 583 posts
put all the HTML in a javascript variable like :

var a =
"some HTML" +
" some more HTML";

then do a

document.write(a);

in the place you wanna insert the HTML
  #3  
Old 09-11-2004
TechSpot Evangelist
 
Location: has left the building
Member since: Aug 2003, 8,165 posts
Thanks DigitAlex,
I'll try that out and let you know.
Sounds simple enough if it works!
  #4  
Old 09-14-2004
TechSpot Evangelist
 
Location: has left the building
Member since: Aug 2003, 8,165 posts
That took a bit of fumbling, but this is the (working) result:

Create a "filename.js" with e.g. text:
Code:
<!-- Start

function dothis()
{
document.write('<SELECT NAME="surname"  CLASS="quoteform">');
document.write('<option selected> Select');
document.write('<option>Allen	');
document.write('<option>Anderson	');
document.write('<option>Barrett	');
etc.
document.write('</select>');
}
dothis();
//  End -->

And in the main HTLM source, you only need to enter something like this:

Code:
Surname:
<script language="JavaScript" src="filename.js"></script>
Closed Thread

Similar Topics
Topic Replies Forum
Javascript problem? 13 Virus and Malware Removal
Javascript problems 6 Software Apps
Need Javascript help 2 Software Apps
How do I re-enable Javascript in IE6? 6 Software Apps

Thread Tools Search this Thread
Search this Thread:

Advanced Search
All times are GMT -4. The time now is 05:40 AM.