Hide/show 2 table rows when having data - html

I need to display 2 empty table row when don't have any data and when they do have data those 2 empty table rows should be hidden. Now i can write the code for display data in the table rows but it doesn't display 2 empty table rows when it doesn't have data, so please help me to solve this problem. thank you.
<table class="message_table" width="1025" border="0" cellspacing="1" cellpadding="5" align="center" bgcolor="#c9c9c9">
<tr style="background-color:#797a7b;">
<td style="color:#fff;">序号</td>
<td style="color:#fff;">模式</td>
<td style="color:#fff;">时时彩返点</td>
<td style="color:#fff;">11选5返点</td>
<td style="color:#fff;">低频返点</td>
<td style="color:#fff;">操作</td>
</tr>
<a4j:repeat value="#{AgentAutoRegBean.reslist}" var="list"
id="dblist" rowKeyVar="keys">
<tr style="background:#{keys%2==1?'#EEEEDD':'#f4f4f4'}">
<td>#{keys+1}</td>
<td>#{list.model}</td>
<td>
<h:outputText value="#{list.pointssc}" converter="PercentConverter"/>
</td>
<td>
<h:outputText value="#{list.point115}" converter="PercentConverter"/>
</td>
<td>
<h:outputText value="#{list.pointdp}" converter="PercentConverter"/>
</td>
<td>
<font color="#5a5a5a">
<a4j:commandLink value="编辑" status="normalStatus" action="#{AgentAutoRegBean.edit}" data="#{AgentAutoRegBean.msg}" oncomplete="edit01(data)">
<f:param name="sign" value="#{list.sign}"/>
</a4j:commandLink>
<rich:spacer width="8"></rich:spacer>
<a4j:commandLink value="网址" onclick="winopen('#{list.sign}');return false;">
</a4j:commandLink>
</font>
</td>
</tr>
</a4j:repeat>
</table>

If you want to fill it later you have to use the var attribute of the a4j:repeat and prepare a list with 2 (empty) elements in the backing bean before access the data and use listeners for fill the list later.

Related

thymeleaf - how to make two cells in a table merge if one is null or empty?

I have a table with 7 columns and I'd like to make two of them merge and display some nice information to the user if there's a null or empty value in a condition check.
I tried something like this, but it didn't work.
<tr th:each="pojo : ${pojoList}">
<td th:text="${pojo.a}"/>
<td th:text="${pojo.b}"/>
<td th:text="${pojo.c}"/>
<td th:text="${pojo.d}"/>
<td th:text="${pojo.e}"/>
// here I test if the value is null or empty, if so the next two columns should merge
<td th:if="${pojo.f.empty}" colspan="2" th:text="#{nice.info}"/>
// if value is not null or empty, the next two columns gets their respective values
<td th:text="${pojo.f}"/>
<td th:text="${pojo.g}"/>
<td>
<a th:href="#{/url/edit(id=${pojo.id})}">
<img width="20px" height="20px" alt="edit" th:src="#{/assets/img/edit.png}" />
</a>
<a th:href="#{/url/remove(id=${pojo.id})}">
<img width="20px" height="20px" alt="remove" th:src="#{/assets/img/delete.png}" />
</a>
</td>
</tr>
What am I not seeing here?
Got it! I used, on a hunch, <th:block> like this:
<th:block th:if="${pojo.f == null}">
<td colspan="2" th:text="#{nice.info}"/>
</th:block>
<th:block th:if="${pojo.f != null}">
<td th:text="${pojo.f}"/>
<td th:text="${pojo.g}"/>
</th:block>
I'm not sure what is not working but you can try the following:
// here I test if the value is null or empty, if so the next two columns should merge
<td th:if="${pojo.f.empty}" colspan="2" th:text="#{nice.info}"/>
// if value is not null or empty, the next two columns gets their respective values
<td th:unless="${pojo.f.empty}" th:text="${pojo.f}"/>
<td th:unless="${pojo.f.empty}" th:text="${pojo.g}"/>
But I think it is better if you going with the th:switch solution (th:switch)

Table colspan and rowspan not working

I'm working on table for design its simple table but its not working for me, here is the design what I want:
and my code is changing after every mins for this output but didn't succeed. Code is
See the [fiddle](http://jsfiddle.net/su4w3ymx/1/)
I updated my code now I'm creating it but now when I want to add notify party in third row it's messing up.
See the fiddle
HTML
<table cellpadding="0" cellspacing="0" width="100%" border="1">
<tr>
<td rowspan="3">SHIPPER/EXPORTER
<br />W8SHIPPING
<br />8 AVIATION CT, Savannah U.S.A.
<br />GA 31408
<br />TEL: +1 912 966 6820</td>
</tr>
<tr>
<td colspan="2">BOOKING NUMBER</td>
</tr>
<tr>
<td colspan="2">EXPORTER REFERENCES</td>
</tr>
</table>
UPDATE 1
Check the fiddle
UPDATE 2
Check the fiddle
UPDATE 3
Check the fiddle if you want to see the full structure created
<table cellpadding="0" cellspacing="0" width="100%" border="1">
<tr>
<td rowspan="2">SHIPPER/EXPORTER
<br />W8SHIPPING
<br />8 AVIATION CT, Savannah U.S.A.
<br />GA 31408
<br />TEL: +1 912 966 6820</td>
<td>BOOKING NUMBER</td>
</tr>
<tr>
<td rowspan="2">
EXPORTER REFERENCES
</td>
</tr>
</table>

How can I get particular field value?

I have one table, in this table two columns and 5 rows are there. In First column have a check box and second column have a data. I want get the second column row value of checked items.
My table id was "tb1", checkbox id "cb1" and second field id "da1".
I want the result like "Data2 and Data5" That means whatever I check, that particular second column(<td>) value.
This is possible, please help me.
If you are using cb2 and da2 for row two, then in javascript you could do:
If data column is td element only:
document.getElementById("da2").innerText
If data column is input element:
document.getElementById("da2").value;
JS Bin
Bind the event on every checkbox and the find second field" with the help of closest
JavaScript
$(function(){
$("#tb1").on('click','input',function(){
var value =($(this).closest('tr').find('[id^=da]').text())
alert(value)
})
})
HTML
<table id="tb1" cellpadding="5" border="1" cellspacing='0' width="200">
<tr>
<td id="cb1"><input type='checkbox' /> </td>
<td id="da1">Data 1</td>
</tr>
<tr>
<td id="cb2"><input type='checkbox' /> </td>
<td id="da2">Data 2</td>
</tr>
<tr>
<td id="cb3"><input type='checkbox' /> </td>
<td id="da3">Data 3</td>
</tr>
<tr>
<td id="cb4"><input type='checkbox' /> </td>
<td id="da4">Data 4</td>
</tr>
</table>

string replace in phpmyadmin while keeping inner text

i need to change quite some html entries in a mysql database. my problem is that some tags need to be replaced while the surrounded code needs to stay the same. in detail: all td-tags in tr-tags with the class "kopf" need to be changed to th-tags (and the addording closing for the tags)
it would not be a problem without the closing tags..
update `tt_content` set `bodytext` = replace(`bodytext`,'<tr class="kopf"><td colspan="2">','<tr><th colspan="2">');
this would work
from what i found the %-sign is used, but how exactly?:
update `tt_content` set `bodytext` = replace(`bodytext`,'<tr class="kopf"><td colspan="2">%</td></tr>','<tr><th colspan="2">%</th></tr>');
i guess this would replace all the code within the old td tags by a %-sign?? how can i achive the needed replacement?
edit: just to clarify things here is a possible entry in the db:
<table class="techDat" > <tbody> <tr class="kopf"> <td colspan="2"> <p><strong>Technical data:</strong></p> </td> </tr> <tr> <td> <p>Operating time depending on battery chargeBetriebszeit je Akkuladung</p> </td> <td> <p>Approx. 4 h</p> </td> </tr> <tr> <td> <p>Maximum volume</p> </td> <td> <p>Approx. 120 dB(A)</p> </td> </tr> <tr> <td> <p>Weight</p> </td> <td> <p>Approx. 59 g</p> </td> </tr> </tbody> </table>
after the mysql replacement it should look like
<table class="techDat" > <tbody> <tr> <th colspan="2"> <p><strong>Technical data:</strong></p> </th> </tr> <tr> <td> <p>Operating time depending on battery chargeBetriebszeit je Akkuladung</p> </td> <td> <p>Approx. 4 h</p> </td> </tr> <tr> <td> <p>Maximum volume</p> </td> <td> <p>Approx. 120 dB(A)</p> </td> </tr> <tr> <td> <p>Weight</p> </td> <td> <p>Approx. 59 g</p> </td> </tr> </tbody> </table>
Try two replaces
update `tt_content` set `bodytext` =
replace(replace(`bodytext`,
'<tr class="kopf"><td colspan="2">','<tr><th colspan="2">'),
'</td></tr>','</th></tr>')
Try updating your records with two queries :
1) for without % sign:
updatett_contentsetbodytext= replace(bodytext,'<tr class="kopf"><td colspan="2">','<tr><th colspan="2">');
2) for % sign
updatett_contentsetbodytext= replace(bodytext,'<tr class="kopf"><td colspan="2">%</td></tr>','<tr><th colspan="2">%</th></tr>')
where instr(bodytext,'%') > 0 ;

dont want to submit form when one of fields value is wrong or left empty

I am using Struts framework in my web application, i am facing problem in my coding when i click on radiobutton doctor hmm it asks for docid and so profile will be updated but if user doesnt give id and select doctor and save profile , menus of patient changes to doctor and user becomes doctor due to getter setter in beans have these values just update function doesnt works ..and same for pathologist..
<html:form action="upAction" enctype="multipart/form-data">
<table>
<tr class="show" id="admhide">
<td align="left" valign="middle" nowrap><bean:message key="sp.type"/></td>
<td align="left" nowrap><html:radio property="type" value="Patient" name="reg" styleId="patradio" onclick="show(this.value);"/>Patient
<html:radio property="type" value="Doctor" name="reg" styleId="docradio" onclick="show(this.value);"/>Doctor
<html:radio property="type" value="Pathologist" name="reg" styleId="pathradio" onclick="show(this.value);"/>Pathologist</td>
</tr>
<tr class="hide" id="doctor">
<td align="left" valign="middle" nowrap><bean:message key="sp.docid"/></td>
<td nowrap align="left" ><html:text property="docid" name="reg" styleId="docid"/></td>
</tr>
<tr class="hide" id="patho">
<td align="left" valign="middle" nowrap><bean:message key="sp.pathoid"/></td>
<td nowrap align="left" ><html:text property="pid" name="reg" styleId="pathid"/></td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle" nowrap><html:submit styleClass="button2" property="method"><bean:message key="userform.upd"/></html:submit></td>
</tr>
</table>
</html:form>
please help me how to do this so that if user fills wrong docid or no docid form dont sets rest values in getter setters and doesnt gets submit .. thankyou ..
I think you need to apply JavaScript checks for Empty fields.
go to this link for understanding Javascript Validations :
http://www.w3schools.com/js/js_form_validation.asp
For a wrong Doc Id, when the form is submitted you need to check the Doc Id first in your code before saving other details otherwise return the same page with errors like "wrong docid".