Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help altering javascript function

Status
Not open for further replies.

ukeen

Technical User
Aug 2, 2000
2
CA
Hi, I have this function that was handed to me. I need to include the values, however, every attempt that I have made produces errors or does not alter the output.&nbsp;&nbsp;Any help would be appreciated.<br>&nbsp;<br>var times = [ &quot;00:00&quot;, &quot;00:30&quot;, &quot;01:00&quot;, &quot;01:30&quot;, &quot;02:00&quot;, &quot;02:30&quot;, &quot;03:00&quot;, &quot;03:30&quot;, &quot;04:00&quot;, &quot;04:30&quot;, &quot;05:00&quot;, &quot;05:30&quot;, &quot;06:00&quot;, &quot;06:30&quot;, &quot;07:00&quot;, &quot;07:30&quot;, &quot;08:00&quot;, &quot;08:30&quot;, &quot;09:00&quot;, &quot;09:30&quot;, &quot;10:00&quot;, &quot;10:30&quot;, &quot;11:00&quot;, &quot;11:30&quot;, &quot;12:00&quot;, &quot;12:30&quot;, &quot;13:00&quot;, &quot;13:30&quot;, &quot;14:00&quot;, &quot;14:30&quot;, &quot;15:00&quot;, &quot;15:30&quot;, &quot;16:00&quot;, &quot;16:30&quot;, &quot;17:00&quot;, &quot;17:30&quot;, &quot;18:00&quot;, &quot;18:30&quot;, &quot;19:00&quot;, &quot;19:30&quot;, &quot;20:00&quot;, &quot;20:30&quot;, &quot;21:00&quot;, &quot;21:30&quot;, &quot;22:00&quot;, &quot;22:30&quot;, &quot;23:00&quot;, &quot;23:30&quot;, &quot;24:00&quot; ];<br><br>function addTimes( timeselected )<br>{<br>var timesindex = getTimesIndex( timeselected );<br>for( var t = 0 ; t &lt; times.length ; t++ ) {<br> document.write(&quot;&lt;option&quot;);<br> if( t == timesindex )<br> document.write(&quot; selected&quot;);<br> document.write(&quot;&gt;&quot;);<br> document.write(times[t]);<br> }<br>}
 
You are referncing a function called getTimesIndex() which I do not see defined.<br><br><br><A HREF="mailto:jared@aauser.com">jared@aauser.com</A>
 
and what's more, you say &quot;I need to include the values, however, every attempt that I have made produces errors or does not alter the output.&quot; but the function you show us only displays the values !!&nbsp;&nbsp;
 
I'm sorry, the function outputs<br>&lt;option&gt;time1&lt;option&gt;time2<br><br>I'm trying to alter the output so that I receive<br>&lt;option value=time1&gt;time1&lt;option value=time2&gt;time2
 
so you just have to replace that line :<br>document.write(&quot;&gt;&quot;);<br><br>with those 3 :<br>document.write(&quot;value=&quot;);<br>document.write(times[t]);<br>document.write(&quot;&gt;&quot;);<br><br>done :]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top