mikezang
asked on
How to show table cell when cell value changed
I have a form as below, the sFilename will be changed in aspx.cs, I hope the table will be showed after sFilename changed, what can I do?
<table border=0>
<tr class='result'><th width=120>¿¿¿¿¿¿¿</th><th width=120>¿¿¿¿¿</th><th width=120>¿¿¿¿¿¿¿¿</th></tr>
<tr class='result'><td align=center id='filename'><% =sFilename %></td><td align=center><% =sGoods %></td><td align=center><% =sResult %></td></tr>
</table><br /><br />
<script type="text/javascript">
$(document).ready(function() {
$('.result').hide();
$('#filename').change(function() {
$('.result').show();
});
});
</script>
ASKER
Thanks for your answer, can you give me a sample.
I have a table in hide mode, when I change the cell value, I hope the table will be showed, that's all, can you help me?
I have a table in hide mode, when I change the cell value, I hope the table will be showed, that's all, can you help me?
Sure. Check this out
<table id="myTable" border=0 onreadystatechange="checkT able();">
<tr class='result'><th width=120>¿¿¿¿¿¿¿</th><th width=120>¿¿¿¿¿</th><th width=120>¿¿¿¿¿¿¿¿</th></t r>
<tr class='result'><td align=center id='filename'><% =sFilename %></td><td align=center><% =sGoods %></td><td align=center><% =sResult %></td></tr>
</table><br /><br />
<Script>
function checkTable()
{
// After && check whether your cell has the value or not
if (document.readyState=="com plete" && <<Check whether the cell has a value>>)
{
document.getElementByTabl e("myTable ").style.d isplay : block;
}
}
</Script>
<table id="myTable" border=0 onreadystatechange="checkT
<tr class='result'><th width=120>¿¿¿¿¿¿¿</th><th width=120>¿¿¿¿¿</th><th width=120>¿¿¿¿¿¿¿¿</th></t
<tr class='result'><td align=center id='filename'><% =sFilename %></td><td align=center><% =sGoods %></td><td align=center><% =sResult %></td></tr>
</table><br /><br />
<Script>
function checkTable()
{
// After && check whether your cell has the value or not
if (document.readyState=="com
{
document.getElementByTabl
}
}
</Script>
ASKER
The problem is I don't know how to check the cell has a value, that is what I want to know
I tried .chage(function().., it seems like not work, how can I check the cell value?
<script type="text/javascript">
$(document).ready(function () {
$('.result').hide();
$('#filename').change(func tion() {
$('.result').show();
});
});
</script>
I tried .chage(function().., it seems like not work, how can I check the cell value?
<script type="text/javascript">
$(document).ready(function
$('.result').hide();
$('#filename').change(func
$('.result').show();
});
});
</script>
Sure. Give your cell an id like I've given. and check it's innerText property.
table id="myTable" border=0 onreadystatechange="checkT able();">
<tr class='result'><th width=120 id="myCell">¿¿¿¿¿¿¿</th><t h width=120>¿¿¿¿¿</th><th width=120>¿¿¿¿¿¿¿¿</th></t r>
<tr class='result'><td align=center id='filename'><% =sFilename %></td><td align=center><% =sGoods %></td><td align=center><% =sResult %></td></tr>
</table><br /><br />
<Script>
function checkTable()
{
// After && check whether your cell has the value or not
if (document.readyState=="com plete" && document.getElementById("m yCell").in nerText.le ngth > 0)
{
document.getElementByTable ("myTable" ).style.di splay : block;
}
}
</Script>
table id="myTable" border=0 onreadystatechange="checkT
<tr class='result'><th width=120 id="myCell">¿¿¿¿¿¿¿</th><t
<tr class='result'><td align=center id='filename'><% =sFilename %></td><td align=center><% =sGoods %></td><td align=center><% =sResult %></td></tr>
</table><br /><br />
<Script>
function checkTable()
{
// After && check whether your cell has the value or not
if (document.readyState=="com
{
document.getElementByTable
}
}
</Script>
ASKER
sorry, can you give me a code as blow? I am very new for ajax.
<script type="text/javascript">
$(document).ready(function () {
$('.result').hide();
$('#filename').innerText.l ength(func tion() {
$('.result').show();
});
});
</script>
<script type="text/javascript">
$(document).ready(function
$('.result').hide();
$('#filename').innerText.l
$('.result').show();
});
});
</script>
We are not using AJAX in the code I've shown. It is RAW JavaScript. Why you need to use AJAX?
are you using AJAX to get the filename after the page is loaded?
are you using AJAX to get the filename after the page is loaded?
ASKER
I have to use AJAX, because I can do it if not use AJAX:)
are you using AJAX to get the filename after the page is loaded?
ASKER
the filename is a id of table td, I updated my page using aspx, then I hope the table is showed after I updated the cell of table.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How about using onreadystatechange on the TD?
http://msdn.microsoft.com/en-us/library/ms536957(VS.85).aspx
Try attaching this event and then change the visibility.
Let me know if you need help on that.
Regards,
Chinmay