StirCrazy Posted April 7, 2007 Share Posted April 7, 2007 I'm trying to get unix time based on data inputted into a drop down menu: example code below:- <select id="dateselector" value="day" class="datedropdown"> <option onChange="updateDate();" value="01" name="inDay" >1</option> <option onChange="updateDate();" value="02" name="inDay" >2</option> <option onChange="updateDate();" value="03" name="inDay" >3</option> <option onChange="updateDate();" value="04" name="inDay" >4</option> ... <select id="dateselector" value="month" class="datedropdown"> <option onChange="updateDate();" value="01" name="inMon" >January</option> <option onChange="updateDate();" value="02" name="inMon" >February</option> <option onChange="updateDate();" value="03" name="inMon" >March</option> ... <select id="dateselector" value="year" class="datedropdown"> <option onChange="updateDate();" value="06" name="inYear" >2006</option> <option onChange="updateDate();" value="07" name="inYear" >2007</option> ... I have no idea how to get the updateDate() function to output unix time into 'var timestamp' as i have very little experience with .js I'm guessing it looks a little like:- function updateDate() { var timestamp = new Date(Date.UTC(document.getElementsByName("inYear").value, (stripLeadingZeroes(document.getElementsByName("inMon").value)-1), stripLeadingZeroes(document.getElementsByName("inDay").value), 0, 0, 0)); timestamp=timestamp.getTime()/1000.0; updateText(); } (updateText(); then updates a text area) Any help to with the correct syntax would be great. Thanks in advance S.C> Quote Link to comment Share on other sites More sharing options...
veridicus Posted April 8, 2007 Share Posted April 8, 2007 Your selects have IDs but your JS is looking for elements by name. Your form elements should have both (name for form submission and ID to grab them with JS). Then use getElementById. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.