Common JSP/HTML & Javascript Problems

31 / Aug / 2012 by Vivek Sachdeva 0 comments

Some of the commonly faced problems are:

1) In case we give different width combinations for cells of different rows, the width combination of first row is accepted and subsequent combinations are neglected.


<tr>
<td width="30%">1.1</td>
<td width="50%">1.2</td>
<td width="20%">1.3</td>
</tr>

<tr><td width="50%">2.1</td>
<td width="40%">2.2</td>
<td width="10%">2.3</td>
</tr>

In this case width of first, second and third cell would be 30%, 50% and 20% for both the rows.

2) If we have defined width combinations for first row cells and we use both colspan and width attribute for cell of other row, then width attribute becomes ineffective.

If we want to have table as shown above, we can have each row with one cell and each of the cells would have a table with single row. That ways, the cells of the row can be arranged as per our specifications and requirements.


<tr>
<td>
<table border="2px" width="100%">
<tr>
<td width="80%">New</td>
<td width="20%">Few</td>
</tr>
</table>
</tr>

<tr>
<td>
<table border="2px" width="100%">
<tr>
<td width="40%">New</td>
<td width="60%">Few</td>
</tr>
</table>
</td>
</tr>

3) One of very common problems that we face in when working with javascript is that we do not get to know what error exactly occurred if the script is not working as expected. We can use try-catch blocks, just as we do in java.

A very basic example:


function division(){
try{
var c = 1/x;
alert(c);
}

catch(e){
alert(<a href="http://e.name" target="_blank">e.name</a> + " " + e.message)
}
}

Some javascript errors and their description:

Hope it helps. :)

Regards.

Vivek Sachdeva

vivek.sachdeva@intelligrape.com

@vivek_sach

FOUND THIS USEFUL? SHARE IT

Leave a comment -