...

View Full Version : how to add text boxes dynamically



venkib097
08-31-2007, 07:44 AM
hi guys i have problem with time sheet.i have 3 shifts.
1.morning (7 am to 4pm)
2.afternoon (2 pm to 11 pm)
3.night (10 pm to 6 am)
these 3 are radio buttons. when i select one radio button ike morning, below the radio buttons it will dispaly two select lists From and To. And the user should submit hourly reports for every hour.
The option values in From select list is 7,8,9,10,11,12,13.14,15,16 likewise)and alternatively in To select list have (7,8,.....so on).
if user select morning shift ,it displays From selct list like 7 and To select list 8.and we provide text box corresponding to select lists for entering description.and i want button right side of text box ,when i click it will automatically add next hour select list From 8 -TO 9 it is also have text box for entering descrption and right side of this have button to add next hour select list .these select lists are added dunamically with one hour time differenece.Please any one help to do this

BarrMan
08-31-2007, 08:28 AM
Umm. Is there a simplier explanation of what you need to do?

2reikis
08-31-2007, 01:08 PM
This represented such an interesting excercise I thought I'd have a shot at what I thought you meant. If it's not, no harm done. Just ignore this post.


.value = (opt+parseInt(i)).toString()
f.slcFrom.options[opt].text = (opt+parseInt(i)).toString();
f.slcTo.options[opt].value = (opt+parseInt(i)+1).toString();
f.slcTo.options[opt].text = (opt+parseInt(i)+1).toString();
obj = document.getElementById("taList")
obj.innerHTML = '<textarea name="taShiftStart" cols="80" rows="10"></textarea>
'
}
}
function addIt() {
f=document.form1
obj=document.getElementById("taList");
obj.innerHTML = '<textarea name="ta' + f.slcFrom.selectedIndex + '" cols="80" rows="10"></textarea>' + obj.innerHTML
inc(f.slcTo,f.slcFrom)
}
function inc() {
for (i=0; i<arguments.length; i++) {
obj=arguments[i]
obj.selectedIndex++
}
}
</script>
</head>
<body>
<form action="#" method="get" name="form1" onSubmit = "return false">

<table cellspacing="0" cellpadding="0">
<tr>
<td>1<sup>st</sup></td>
<td>2<sup>nd</sup></td>
<td>3<sup>rd</sup></td>
</tr>
<tr>
<td><input name="rdShift" type="radio" value="7" checked onClick="fnSetShift(this.value)"></td>
<td><input name="rdShift" type="radio" value="14" onClick="fnSetShift(this.value)"></td>
<td><input name="rdShift" type="radio" value="22" onClick="fnSetShift(this.value)"></td>
</tr>
</table>

<p>
From:
<select name="slcFrom">
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
</select>
&nbsp;&nbsp;&nbsp;To:
<select name="slcTo">
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
</select>
&nbsp;&nbsp;&nbsp;
<input type="button" name="addEntry" value="Add Entry" onClick='addIt();'>
</p>
<p id="taList">
<textarea name="taShiftStart" cols="80" rows="10"></textarea>
</p>
<p>&nbsp;</p>
</form>

</body>
</html>


HTH
2reikis

garydarling
08-31-2007, 05:36 PM
Nice work! I tried it both FF and IE7; in FF I can't get the text field to keep the text when adding a new entry. Any thoughts?

Gary



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum