natasha23 Posted April 11, 2009 Share Posted April 11, 2009 i am trying to link an array from an external javascript file to be displayed in a drop down box this is my code: <script type="text/javascript"><!--hide from no-script browsers document.write(message1); document.write('<select name="Title" size="1" >'); for (i=0; i<titles.length; i++) { document.write('<option value=' +titles[i]+ '>' +titles[i]+ '</option>'); } document.write('</select>');// hidden scripts above --></script> im not sure why it isnt working for some reason the external javascript file is not populating the drop down box.if anyone could help that would be greatthanks in advance Link to comment Share on other sites More sharing options...
Synook Posted April 11, 2009 Share Posted April 11, 2009 What is the rest of the code? Link to comment Share on other sites More sharing options...
mstransky Posted April 11, 2009 Share Posted April 11, 2009 i am trying to link an array from an external javascript file to be displayed in a drop down box this is my code:<script type="text/javascript"><!--hide from no-script browsers document.write(message1); document.write('<select name="Title" size="1" >'); for (i=0; i<titles.length; i++) { document.write('<option value=' +titles[i]+ '>' +titles[i]+ '</option>'); } document.write('</select>');// hidden scripts above --></script> im not sure why it isnt working for some reason the external javascript file is not populating the drop down box.if anyone could help that would be greatthanks in advance If you are useing IE first try looking at the bottom of the window to see if you are not getting an error, if you see the error icon just click it,Some times simple mistakes like could not find file, worng location, or line error will tell you where it haulted.2nd make sure you are not trying to document.write it before you set the varlike so<script type="text/javascript" src="externaljsfilename.js"></script><script type="text/javascript"><!--hide from no-script browsers document.write(message1); document.write('<select name="Title" size="1" >'); for (i=0; i<titles.length; i++) { document.write('<option value=' +titles+ '>' +titles+ '</option>'); } document.write('</select>');// hidden scripts above --></script>but in that external script you need to:-----example----externaljsfilename.js------------<!--var message1="Welcome back";// -->---------------endofjs----------------what ever you wish to name your varibles make sure they are named before you try to telljs to write them.If that is not the case I think you are trying to code this FIXIT???? document.write('<option value=' +titles+ '>' + message1 + '</option>'); Link to comment Share on other sites More sharing options...
jeffman Posted April 11, 2009 Share Posted April 11, 2009 Your external script doesn't contain <script> tags, I hope. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.