Using checkbox to change dropdown lists

M

Mark Snodgrass

I am trying to create a timecard that has a checkbox that the user can
check if they worked normal hours that will change the dropdown lists
for that day to a standard workday in order to save the time. I can
get it to work if I hard code the select names, but I am going to have
the form display 5 days at a time and I can't figure out how to make
it work when I have multiple days displayed. Here is my code that I
made for the hard-coded version. I just can't figure out how to work
with the variable. Hopefully someone can help me.
<script language='javascript'>
function standardDay(i) {
var i;
document.form1.timeinA.value = 8;
document.form1.lunchoutA.value = 12;
document.form1.lunchinA.value = 13;
document.form1.timeoutA.value = 16.5;

}
</script>

<form name='form1' method='post' action='timecardsubmit.asp'>
<table>
<tr><th>Date</th><th>Standard?</th><th>Time In</th><th>Lunch Out</th>
<th>Lunch In</th><th>Time Out</th></tr>
<tr>
<td><input type='text' name='dtA' size='7' value='<%=Date()%>'></td>
<td align='center'><input type='checkbox' value='1' name='standardA'
onClick='standardDay("A")'></td>
<td><select name='timeinA'><!-- #include file=timechart.asp
--></select></td>
<td><select name='lunchoutA'><!-- #include file=timechart.asp
--></select></td>
<td><select name='lunchinA'><!-- #include file=timechart.asp
--></select></td>
<td><select name='timeoutA'><!-- #include file=timechart.asp
--></select></td>
</tr>
<tr>
<td><input type='text' name='dtB' size='7' value='<%=Date()%>'></td>
<td align='center'><input type='checkbox' value='1' name='standardB'
onClick='standardDay("B")'></td>
<td><select name='timeinB'><!-- #include file=timechart.asp
--></select></td>
<td><select name='lunchoutB'><!-- #include file=timechart.asp
--></select></td>
<td><select name='lunchinB'><!-- #include file=timechart.asp
--></select></td>
<td><select name='timeoutB'><!-- #include file=timechart.asp
--></select></td>
</tr>
</table>
<input type='submit' value='Submit'>
</form>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,082
Messages
2,570,588
Members
47,209
Latest member
Ingeborg61

Latest Threads

Top