sammySeltzer
asked on
I need a helping set of eyes trying to figure out why my code isn't working.
I have these controls on my gridview markup page.
Then this js:
What I am trying to accomplish really is to allow users to click a checkbox and have current date get inserted into the currentDate control.
Then if the users decide to uncheck the checked box(es), the inserted dates get removed.
I am not getting any errors. However, when you click any checkbox, no date is getting inserted and of course none is getting removed since none is inserted.
I have been looking at this for 2 hours.
Any assistance is greatly appreciated.
<ItemTemplate>
<asp:CheckBox ID="ckb" runat="server" onclick="Box_Click(this)" />
</ItemTemplate>
<ItemTemplate>
<asp:TextBox runat="server" style="border: none;" ID="currentDate"></asp:TextBox>
</ItemTemplate>
Then this js:
function Box_Click(cb) {
var tr = cb;
var inps = tr.getElementsByTagName("input");
if(cb.checked == 1){ // CheckBox checked condition
while (tr.tagName != "TR") {
tr = tr.parentNode;
if (tr == null) return; // something went wrong
}
for (var i = 0; i < inps.length; ++i) {
var inp = inps[i];
if (inp.name.indexOf("currentDate") >= 0) {
inp.value = getDate();
break;
}
}
}
else{
for (var i = 0; i < inps.length; ++i) {
var inp = inps[i];
inp.value = '';
}
}
}
What I am trying to accomplish really is to allow users to click a checkbox and have current date get inserted into the currentDate control.
Then if the users decide to uncheck the checked box(es), the inserted dates get removed.
I am not getting any errors. However, when you click any checkbox, no date is getting inserted and of course none is getting removed since none is inserted.
I have been looking at this for 2 hours.
Any assistance is greatly appreciated.
ASKER
Error: Object doesn't support this property or method on the following line:
var txtBox = document.getElementByID(tx tBoxID);
var txtBox = document.getElementByID(tx
Are you getting txtBoxID as null?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Fantastic job, it worked!!!!
Thank you very much.
Thank you very much.
ASKER
Excellent job. I thought I was good at javascript.
Thank you very much
I will like to make the date persist.
In other words, I am using paging (gridview paging).
When I go to a different page, the inserted dates disappear.
I will like them stay inserted no matter what page you go to until the checkbox is uncheked.
Is this possible?
If yes, pls let me know and I will post the question separately.
Thanks again
Thank you very much
I will like to make the date persist.
In other words, I am using paging (gridview paging).
When I go to a different page, the inserted dates disappear.
I will like them stay inserted no matter what page you go to until the checkbox is uncheked.
Is this possible?
If yes, pls let me know and I will post the question separately.
Thanks again
Open in new window
Open in new window