Hey all,
Got an easy one, well, what I would normally been ok with but must've been working too hard - I can't see why I'm having this problem.
Just trying to add items to a multiple select listbox:
Code:<SELECT Name="servTimeRange" multiple="multiple"> <?php showTimeRange(); ?> </SELECT>Code:<a href="#" onClick="addTimeRange(document.getElementById('servTimeFrom').value,document.getElementById('servTimeTo').value); return false;">Add</a>Problem is just on the last line of the last group of code here, giving me the "object does not support this property or method" message - and it looks right to me, so probably needs a fresh pair of eyes.Code:function addTimeRange(from,to) { var tstampFrom; var tstampTo; arrFrom = from.split(":"); arrTo = to.split(":"); if (document.serviceAdd.servTimeFromM.options[document.serviceAdd.servTimeFromM.selectedIndex].text == "pm") { (arrFrom[0] += 12); } if (document.serviceAdd.servTimeToM.options[document.serviceAdd.servTimeToM.selectedIndex].text == "pm") { (arrTo[0] += 12); } tstampFrom = arrFrom[0]+':'+arrFrom[1]+':00'; tstampTo = arrTo[0]+':'+arrTo[1]+':00'; var opt = document.createElement("option"); opt.text = from+document.serviceAdd.servTimeFromM.options[document.serviceAdd.servTimeFromM.selectedIndex].text+' - '+to+document.serviceAdd.servTimeToM.options[document.serviceAdd.servTimeToM.selectedIndex].text; opt.value= tstampFrom+' - '+tstampTo; document.getElementByID("servTimeRange").options.add(opt); }
I've also noticed that on the line "arrFrom[0] += 12", that despite the value in this array is a number, it's concatenating it - what's the best way to convert that value to an integer?
Thanks all,
Jess.


Reply With Quote

Bookmarks