It seems that <hr> creates newlines - html

Does "hr" element create new lines similarly like paragraphs elements "p" ? Because I added an "hr" element to my table element and it gives a result like in this image :
EDIT :
<fieldset style="border: solid 1px "><legend>alertes offres/demandes</legend>
<div><img src="http://localhost/bazarmada/pages/img/icons/plus.png" alt="Ajouter un alerte d'abonnement" /></div>
<div style="background-color:#cafbb7;"><b>Marché : </b>Ambalavao</div>
<table width="100%">
<tr>
<td align="center" width="25%">Mardi</td>
<td align="center" width="60%">Akotry</td>
<td align="center" width="5%"><input type="checkbox" value="12" checked onchange="aboDesabo($(this), $(this).val(), 'Akotry');" /></td>
<td align="center" width="5%"><img src="http://localhost/bazarmada/pages/img/icons/edit.png" alt="Modifier" style="height:10px;width:10px;" /></td>
<td align="center" width="5%"><a id="a_del" href="#" onclick="ask(12);"><img src="http://localhost/bazarmada/pages/img/icons/cross.png" alt="Supprimer" style="height:10px;width:10px;" /></a></td>
</tr>
<tr>
<td align="center" width="25%"></td>
<td align="center" width="60%">Akotry gasy</td>
<td align="center" width="5%"><input type="checkbox" value="13" onchange="aboDesabo($(this), $(this).val(), 'Akotry gasy');" /></td>
<td align="center" width="5%"><img src="http://localhost/bazarmada/pages/img/icons/edit.png" alt="Modifier" style="height:10px;width:10px;" /></td>
<td align="center" width="5%"><a id="a_del" href="#" onclick="ask(13);"><img src="http://localhost/bazarmada/pages/img/icons/cross.png" alt="Supprimer" style="height:10px;width:10px;" /></a></td>
</tr>
<tr>
<td align="center" width="25%"></td>
<td align="center" width="60%">Akotry sebota</td>
<td align="center" width="5%"><input type="checkbox" value="14" onchange="aboDesabo($(this), $(this).val(), 'Akotry sebota');" /></td>
<td align="center" width="5%"><img src="http://localhost/bazarmada/pages/img/icons/edit.png" alt="Modifier" style="height:10px;width:10px;" /></td>
<td align="center" width="5%"><a id="a_del" href="#" onclick="ask(14);"><img src="http://localhost/bazarmada/pages/img/icons/cross.png" alt="Supprimer" style="height:10px;width:10px;" /></a></td>
</tr>
<tr>
<td align="center" width="25%"></td>
<td align="center" width="60%">Akotry tsipala</td>
<td align="center" width="5%"><input type="checkbox" value="15" checked onchange="aboDesabo($(this), $(this).val(), 'Akotry tsipala');" /></td>
<td align="center" width="5%"><img src="http://localhost/bazarmada/pages/img/icons/edit.png" alt="Modifier" style="height:10px;width:10px;" /></td>
<td align="center" width="5%"><a id="a_del" href="#" onclick="ask(15);"><img src="http://localhost/bazarmada/pages/img/icons/cross.png" alt="Supprimer" style="height:10px;width:10px;" /></a></td>
</tr>
</table>
<div style="background-color:#cafbb7;"><b>Marché : </b>Merimandroso</div>
<table width="100%">
<tr>
<td align="center" width="25%">Lundi</td>
<td align="center" width="60%">Peta kofehy</td>
<td align="center" width="5%"><input type="checkbox" value="11" checked onchange="aboDesabo($(this), $(this).val(), 'Peta kofehy');" /></td>
<td align="center" width="5%"><img src="http://localhost/bazarmada/pages/img/icons/edit.png" alt="Modifier" style="height:10px;width:10px;" /></td>
<td align="center" width="5%"><a id="a_del" href="#" onclick="ask(11);"><img src="http://localhost/bazarmada/pages/img/icons/cross.png" alt="Supprimer" style="height:10px;width:10px;" /></a></td>
</tr>
<tr><td colspan="5"><hr /></td></tr>
<tr>
<td align="center" width="25%">Jeudi</td>
<td align="center" width="60%">Rary penjy</td>
<td align="center" width="5%"><input type="checkbox" value="19" checked onchange="aboDesabo($(this), $(this).val(), 'Rary penjy');" /></td>
<td align="center" width="5%"><img src="http://localhost/bazarmada/pages/img/icons/edit.png" alt="Modifier" style="height:10px;width:10px;" /></td>
<td align="center" width="5%"><a id="a_del" href="#" onclick="ask(19);"><img src="http://localhost/bazarmada/pages/img/icons/cross.png" alt="Supprimer" style="height:10px;width:10px;" /></a></td>
</tr>
</table>
So how to remove the blank lines above and below the "hr" element ?

Default <hr> tag shows a horizontal line. But in your case there can be a CSS rule which override the default look. Use inspect element and check the matching CSS rule for the hr tag inside the table.
My Test Test

Related

How can I move the "contact us" form to the center?

I am helping a friend build her website. I am trying to install Recaptcha page on her website because her HTML is really old. I accidentally deleted the html code for her contact us page so now I am trying to rebuild the page. It's very basic but for the life of me, I can't move the contact us form to the center of the page. Could someone send some code for me to set the "contact us" form to the center of the page?
I pasted this code to build a form:
<div class="container">
<div style="text-align:center">
<h2>Contact Us</h2>
</div>
<div class="row">
<div class="column">
</div>
<div class="column">
<form action="/action_page.php">
<label for="fname">Name</label>
<input type="text" id="name" name="name" placeholder="Your name..">
<label for="email">Email</label>
<input type="text" id="email" name="Email" placeholder="Your email...">
<label for="subject">Subject</label>
<textarea id="subject" name="subject" placeholder="Write something.." style="height:170px"></textarea>
<input type="submit" value="Submit">
</form>
</div>
</div>
</div>
Because I lost the original contact us page I copied the code from one of her other pages and am trying to find where I can implement the form on the page. This is the page code I copied on the contact us form""
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fidelis Design & Construction, LLC</title>
<style type="text/css">
<!--
body {
background-image: url(BGs/RH.png);
background-repeat: repeat-x;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style1 {
background-repeat: no-repeat;
}
.style2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 0.689em;
color: #FFFFFF;
}
.style9 { font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
color: #FFFFFF;
}
.style3 {
font-family: Arial, Helvetica, sans-serif;
font-size: 0.689em;
color: #333;
}
.style6 {
color: #000033;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
text-decoration:none;
}
a:hover {
color: #A52113;
}
.style7 {
color: #A52113;
font-weight: bold;
}
.style10 {
font-family: Arial, Helvetica, sans-serif;
font-size: 0.8125em;
color: #333;
}
.style11 {
color: #A52113;
font-size: medium;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
}
.style12 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #A52113;
font-weight: bold;
}
</style>
</head>
<body>
<table width="1045" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="200" height="270" align="center" bgcolor="#000033"><img src="BGs/logo.jpg" alt="Fidelis Design and Construction" width="135" height="189" border="0" longdesc="http://www.fidelisdc.com" /></td>
<td width="845" rowspan="5" align="left" valign="top"><table width="775" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="93"> </td>
<td width="137"> </td>
<td width="170"> </td>
<td width="75"> </td>
<td width="175"> </td>
<td width="125"> </td>
</tr>
<tr>
<td align="left" valign="top"><img src="BGs/sdvosb_logo_alt.png" width="93" height="89" /></td>
<td colspan="5"><table width="682" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="30" colspan="5" align="right" valign="bottom" background="BGs/HD.png"><table width="682" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right"></td>
</tr>
<tr>
<td align="right"><span class="style3"> <span class="style4"><span class="style7">Corporate Headquarters :</span></span> 408 East 4th Street, Suite 308, Bridgeport, PA 19405. <span class="style4"><span class="style7">P</span></span> (610) 277-7094 <span class="style4"> <span class="style7">F</span></span> (610) 277-7095<span class="style4"> </span></span></td>
</tr>
</table></td>
</tr>
<tr>
<td height="20"> </td>
<td colspan="4" align="right" valign="bottom"><span class="style6">Home | About Our Founder | Current Projects | Service Strategy | Contact Us </span></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" rowspan="2"><img src="BGs/SS.png" width="129" height="16" /></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="20" colspan="6" align="left" class="style10">At FDC we are operations driven, providing our clients with exceptional services and expertise, resulting in the highest quality projects </td>
</tr>
<tr>
<td height="20" colspan="6" align="left"><span class="style10">delivered in the safest manner. </span></td>
</tr>
<tr>
<td height="20" colspan="6" align="left" class="style10">FDC seeks to develop loyal, long-term client relationships which result in desired profits, strategic partnerships and opportunities.</td>
</tr>
<tr>
<td height="20" colspan="6" align="left"> </td>
</tr>
<tr>
<td height="20" colspan="4" align="left" class="style10"><strong>Our services include:</strong></td>
<td colspan="2" rowspan="9" align="right"> </td>
</tr>
<tr>
<td height="20" colspan="4" align="left"><span class="style11">• </span><span class="style10">Construction capabilities using state-of-the-art technology & equipment</span></td>
</tr>
<tr>
<td height="20" colspan="4" align="left" class="style10"><span class="style11">• </span>Comprehensive estimating and pricing procedures</td>
</tr>
<tr>
<td height="20" colspan="4" align="left" class="style10"><span class="style11">• </span>Critical path sequencing</td>
</tr>
<tr>
<td height="20" colspan="4" align="left" class="style10"><span class="style11">• </span>Design-Build Contracting Capabilities</td>
</tr>
<tr>
<td height="20" colspan="4" align="left" class="style10"><span class="style11">• </span>Materials procurement </td>
</tr>
<tr>
<td height="20" colspan="4" align="left" class="style10"><span class="style11">• </span>Project management </td>
</tr>
<tr>
<td height="20" colspan="4" align="left" class="style10"><span class="style11">• </span>Subcontractor prequalification </td>
</tr>
<tr>
<td height="20" colspan="4" align="left" class="style10"><span class="style11">• </span>Value engineering and constructability reviews</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="15"> </td>
</tr>
<tr>
<td height="135" align="center" bgcolor="#EFEFEF"><table width="160" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="39" colspan="2" background="BGs/PDFHeader.png" class="style1"> </td>
</tr>
<tr>
<td width="45" align="center"><a href="PDF/philadelphia_weekly_rbennett.pdf" target="_blank" ><img src="BGs/pdf_icon.jpg" width="32" height="33" border="0" title="Click to download / open this document" /></a></td>
<td width="115"><img src="BGs/Readmore.png" width="113" height="26" border="0" title="Click to download / open this document" /></td>
</tr>
</table></td>
</tr>
<tr>
<td height="15"> </td>
</tr>
<tr>
<td height="265" align="center" bgcolor="#000033"><table width="160" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="170" height="25" background="BGs/Contact.png" class="style1"> </td>
</tr>
<tr>
<td height="18" align="left"><span class="style12">Corporate Headquarters :</span></td>
</tr>
<tr>
<td height="18" align="left" class="style2">408 East 4th Street</td>
</tr>
<tr>
<td height="18" align="left" class="style2">Suite 308</td>
</tr>
<tr>
<td height="18" align="left" class="style2">Bridgeport, PA 19405</td>
</tr>
<tr>
<td height="18" align="left"><span class="style2"><strong>P</strong> (610) 277-7094</span></td>
</tr>
<tr>
<td height="18" align="left" class="style2"><strong>F</strong> (610) 277-7095</td>
</tr>
<tr>
<td height="18" align="left" class="style2">--------------------------------------</td>
</tr>
<tr>
<td align="left"><img src="BGs/Email.png" width="103" height="52" border="0" title="Contact Us"/></td>
</tr>
<tr>
<div class="container">
<div style="text-align:right">
<h2>Contact Us</h2>
</div>
<div class="row">
<div class="column">
</div>
<div class="column">
<form action="/action_page.php">
<label for="fname">Name</label>
<input type="text" id="name" name="name" placeholder="Your name..">
<label for="email">Email</label>
<input type="text" id="email" name="Email" placeholder="Your email...">
<label for="subject">Subject</label>
<textarea id="subject" name="subject" placeholder="Write something.." style="height:170px"></textarea>
<input type="submit" value="Submit">
</form>
</div>
</div>
</div>
</tr>
</table></td>
</tr>
<tr>
<td height="15"> </td>
<td> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="40" bgcolor="#000033"><table width="1045" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="524" align="left"><span class="style9">Copyright © 2015, Fidelis Design & Construction, LLC. All Rights Reserved.</span></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
You can apply display: flex; and justify-content: center;" to the column class that's wrapping you form. I would however, suggest adding a differently named class to it to avoid interference with the column class just before it. e.g. <div class="column form-wrapper">

Html table - why does my third row appear in second

Why does the below html yield a table of 2x2 cells instead of 3 rows, 1st with 2 cells and the next 2 with one cell spanning 2?
<table cellpadding="5" width="200">
<tr>
<td><img id="Button1_logoImg" src="" style="height:75px;width:75px;" alt="sButton1_logoImg" /></td><td><img id="Button1_errorImg" src="" style="height:50px;width:50px;" alt="Button1_logoImg" /></td>
</tr>
<tr>
<td width="100%" rowspan="2"><input name="Button1$mainTextTb" type="text" value="changed" id="Button1_mainTextTb" style="font-size:20pt;width:180px;" /></td>
</tr>
<tr>
<td rowspan="2" width="100%"><span id="Button1_subTextLbl" style="font-size:12pt;">sub text</span></td>
</tr>
</table>
Replace your rowspan with colspan in row 2 and 3.
your code
<table cellpadding="5" width="200">
<tr>
<td><img id="Button1_logoImg" src="" style="height:75px;width:75px;" alt="sButton1_logoImg" /></td><td><img id="Button1_errorImg" src="" style="height:50px;width:50px;" alt="Button1_logoImg" /></td>
</tr>
<tr>
<td width="100%" rowspan="2"><input name="Button1$mainTextTb" type="text" value="changed" id="Button1_mainTextTb" style="font-size:20pt;width:180px;" /></td>
</tr>
<tr>
<td rowspan="2" width="100%"><span id="Button1_subTextLbl" style="font-size:12pt;">sub text</span></td>
</tr>
</table>
Replace rowspan with colspan
Edited code
<table cellpadding="5" width="200">
<tr>
<td><img id="Button1_logoImg" src="" style="height:75px;width:75px;" alt="sButton1_logoImg" /></td><td><img id="Button1_errorImg" src="" style="height:50px;width:50px;" alt="Button1_logoImg" /></td>
</tr>
<tr>
<td width="100%" colspan="2"><input name="Button1$mainTextTb" type="text" value="changed" id="Button1_mainTextTb" style="font-size:20pt;width:180px;" /></td>
</tr>
<tr>
<td colspan="2" width="100%"><span id="Button1_subTextLbl" style="font-size:12pt;">sub text</span></td>
</tr>
</table>

phpquery: Extracting all hyperlinks with same class id?

Please help me to construct a jquery (phpquery) to parse the below sample to extract all the url's with the class "myblue". I am trying to make an app that displays the data from those url's.
<table width="100%" cellspacing="1" cellpadding="2" border="0">
<tbody>
<tr>
<td class="inputtxt" height="20" bgcolor="#E4E4E4" colspan="2">
<b>Notices</b>
</td>
</tr>
<tr valign="top">
<td class="inputtxt" width="7%" valign="top" align="center">»</td>
<td width="93%" valign="top">
<a class="myblue" target="_blank" href="http://example.comn/"> Some Text</a>
</td>
</tr>
</tbody>
</table>
<table width="100%" cellspacing="1" cellpadding="2" border="0">
<tbody>
<tr>
<td class="inputtxt" height="20" bgcolor="#E4E4E4" colspan="2">
<b>Info</b>
</td>
</tr>
<tr valign="top">
<td class="inputtxt" width="7%" valign="top" align="center">»</td>
<td width="93%" valign="top">
<a class="myblue" target="_blank" href="xxxx.html"> Some Text</a>
</td>
</tr>
var urls=[];
$('a.myblue').each(function(){
urls.push($(this).attr('href'));
})
or
var urls = $('a.myblue').map(function () {
return $(this).attr('href');
})
If you need to extract them all you can loop through like this -
$('a.myblue').each(function() {
console.log( $(this).attr('href') );
});

How to remove gaps between the tables and tr

<table width="33%" border="0" border-spacing: 0px; cellpadding="0" cellspacing="0">
<tr>
<td colspan="4"><img src="01.png" width="619" height="143" " /></td>
</tr>
<tr>
<td height="13" valign="top"><img 02.png" width="75" height="13" /></td>
<td width="32%" valign="top"><img src="03.png" width="200" height="13" /></td>
<td width="56%" colspan="2" valign="top"><04.png" width="344" height="13" /></td>
</tr>
<tr>
<td colspan="4" valign="top"><img 05.png" width="619" height="150" /></td>
</tr>
<tr>
<td colspan="4" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="85%"><img src="06.png" width="474" height="28" /></td>
<td width="11%"><img src="07.png" width="71" height="28" /></td>
<td width="4%"><img src="08.png" width="74" height="28" /></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="4" valign="top"><img src="09.png" width="619" height="144" /></td>
</tr>
<tr>
<td colspan="4" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="76%" height="32"><img src="10.png" width="474" height="32"/></td>
<td width="12%"><img src="11.png" width="71" height="32"/></td>
<td width="12%"><img src="12.png" width="74" height="32"/></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="4" valign="top"><img src="13.png" width="619" height="140" /></td>
</tr>
<tr>
<td colspan="4" valign="top"><table width="99%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="76%"><img src="14.png" width="474" height="36"/></td>
<td width="12%"><img src="15.png" width="71" height="36" /></td>
<td width="12%"><img src="16.png" width="74" height="36"/></td>
</tr>
</table></td>
</tr>
<tr>
<td height="109" colspan="4" rowspan="2" valign="top"><img 19.png" width="619" /></td>
</tr>
</table>
I have this code in my email template. When I compile it on my local page, it works fine, but when I send it though email, gaps are appearing in between the lines and tables. I tried this also
<style>
table { border-spacing: 0px; }
</style>
But not worked. Anybody know about this issue?
Or how I should print it in php? so that it sends as an image in email. Because after receiving an email, when I forward it, then its shows me correct because it become an image. So I am thinking to make it as an image before shooting email in the script. But how can I print this html in php?
<table ... border-spacing: 0px; ...>
This isn't valid markup. border-spacing would be put within a style property:
<table ... style="border-spacing: 0px;" ...>
To remove the spacing, you'd simply add:
table {
border-collapse: collapse;
}
try this
<table cellspacing="0" cellpadding="0">
</table>

not able to hide div

I have combo box which needs to be displayed based on the option i select,
but when i set display none to div it is not getting hidden. what could be the problem.
below is the html code and java script
<div id="addBanks" style="display: none" style="overflow: auto;height: 75%">
<table id="commonBodyTable" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<table width="100%" align="center" class="tableBorder2" border="0" cellpadding="2" cellspacing="0">
<tr>
<td colspan="4" class="mainheader">Add Banks</td>
</tr>
<tr class="darkrow">
<td width="30%" class="textalign">Bank Code</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="bankcode" id="bankcode" maxlength="20" /></td>
</tr>
<tr class="lightrow">
<td width="30%" class="textalign">Bank Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="bankname" id="bankname" maxlength="20" /></td>
</tr>
<tr class="darkrow">
<td width="30%" class="textalign">Branch Code</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="branchcode" id="branchcode" maxlength="20" /></td>
</tr>
<tr class="lightrow">
<td width="30%" class="textalign">IFSC Code</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" ><input type="text" class="textbox" name="ifsccode" id="ifsccode" maxlength="20" /></td>
</tr>
<tr class="darkrow">
<td width="30%" class="textalign">Country</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" class="textfieldalign"><select class="combobox" name="countryid" id="countryid" onchange="getStates(this.value)">
<option value="" >- - - Select Country Name - - -</option>
</select></td>
</tr>
<tr class="lightrow">
<td width="30%" class="textalign">State</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" class="textfieldalign"><select class="combobox" name="stateid" id="stateid">
<option value="" >- - - Select State Name - - -</option>
</select></td>
</tr>
<tr class="darkrow">
<td width="30%" class="textalign">District Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" >
<select class="combobox" name="districtid" id="districtid">
<option value="" >- - - Select District Name - - -</option>
</select></td>
</tr>
<tr class="lightrow">
<td width="30%" class="textalign">Town or Village</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign">
Town <input type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="townOpt" onclick="enableVillageOrTown(this)"/>
Village <input type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="villageOpt" onclick="enableVillageOrTown(this)"/>
</td>
</tr>
<div id="villageDiv" style="display: none;">
<tr class="darkrow">
<td width="30%" class="textalign">Village Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" >
<select class="combobox" name="villageid" id="villageid">
<option value="" >- - - Select Village Name - - -</option>
</select></td>
</tr>
</div>
<tr class="darkrow">
<div id="townDiv" style="display: none;">
<td width="30%" class="textalign">Town Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" >
<select class="combobox" name="townid" id="townid">
<option value="" >- - - Select Town Name - - -</option>
</select></td>
</div>
</tr>
<tr class="darkrow">
<td width="30%" class="textalign"> </td>
<td width="5%" class="mandatory"> </td>
<td width="65%" colspan="2" class="textfieldalign" ><input type="button" class="submitbu" name="save" id="save" value="Save" onclick="saveState()">
<input type="button" class="submitbu" name="cancel" id="cancel" value="Cancel" onclick="cancelAddState();"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
and my java script :
function enableVillageOrTown(opt){
var optionValue = opt.value;
if(optionValue=='townOpt'){
document.getElementById("townDiv").style.display = "";
document.getElementById("villageDiv").style.display = 'none';
}
if(optionValue=='villageOpt'){
document.getElementById("villageDiv").style.display = "";
document.getElementById("townDiv").style.display = 'none';
}
}
UPDATE :
<div id="villageDiv" style="display: none;">
<tr class="darkrow">
<td width="30%" class="textalign">Village Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" >
<select class="combobox" name="villageid" id="villageid">
<option value="" >- - - Select Village Name - - -</option>
</select></td>
</tr>
</div>
also this is not properly aligned when
<tr class="lightrow">
<td width="30%" class="textalign">Town or Village</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign">
Town <input type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="townOpt" onclick="enableVillageOrTown(this)"/>
Village <input type="radio" class="textbox" name="optTownOrVillage" id="optTownOrVillage" value="villageOpt" onclick="enableVillageOrTown(this)"/>
</td>
</tr>
this is not hidden when the page first time loads
Please help me to find the problem
Regards
Try this code, if it works for you
function enableVillageOrTown(opt){
var optionValue = opt.value;
if(optionValue=='townOpt'){
document.getElementById("townDiv").style.display = "";
document.getElementById("villageDiv").style.display = "none";
}
if(optionValue=='villageOpt'){
document.getElementById("villageDiv").style.display = "";
document.getElementById("townDiv").style.display = "none";
}
}
For that your should use this code for HTML
<!--<div >-->
<tr class="darkrow" id="villageDiv" style="display: none;">
<td width="30%" class="textalign">Village Name</td>
<td width="5%" class="mandatory">*</td>
<td width="65%" colspan="2" class="textfieldalign" >
<select class="combobox" name="villageid" id="villageid">
<option value="" >- - - Select Village Name - - -</option>
</select></td>
</tr>
<!--</div>-->
Remove the DIVs that you are trying to manipulate and just hide or show the TRs that contain the drop downs.
I have tried the code you provided and the results are correct: http://jsfiddle.net/6mKtZ/
...meaning that div id="villageDiv" style="display: none;" is hidden and the only thing that shows up on the page is "?"