Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Thursday, January 12, 2012

HTML Month Dropdownlist

This code in HTML dropdownlist for month. I has a month name on user view in the dropdown.Every month name bind with month numeric value.

Tuesday, January 3, 2012

How to get the javascript objects in html body tag

____________________________________________

index.jsp
____________________________________________

<html>
<head>
<script>
function jsAdd()
{

var temp=document.getElementById("count");
var values=temp.value;
alert(""+values);

var parent = document.getElementById("family");
div = document.createElement("div");
var tbl=div.appendChild(document.createElement("table"));
var tb=tbl.appendChild(document.createElement("tbody"));
var tr=tb.appendChild(document.createElement("tr"));
var td=tr.appendChild(document.createElement("td"));
parent.appendChild(div);

var oSelect=document.createElement("select");

var option1 = document.createElement("option");
var t = document.createTextNode("Parent");
option1.setAttribute("value","Parents");
option1.appendChild(t);
oSelect.appendChild(option1);

var option2 = document.createElement("option");
var t = document.createTextNode("Spose");
option2.setAttribute("value","Spose");
option2.appendChild(t);
oSelect.appendChild(option2);

var option3 = document.createElement("option");
var t = document.createTextNode("Chaild");
option3.setAttribute("value", "Chaild");
option3.appendChild(t);
oSelect.appendChild(option3);

var option4 = document.createElement("option");
var t = document.createTextNode("Other");
option4.setAttribute("value", "Other");
option4.appendChild(t);
oSelect.appendChild(option4);
oSelect.name="rel"+values;
var fname=document.createElement("input");
fname.type="text";
fname.value="Enter name";
fname.name="name"+values;
var age=document.createElement("input");
age.type="text";
age.value="Enter Age";
age.name="age"+values;
td.appendChild(oSelect);
td.appendChild(fname);
td.appendChild(age);

temp.value=parseInt(values)+1;
}

function count()
{
document.getElementById("count").value=0;
}

</script>
</head>
<body onload="count()">
<form action="./submit.jsp" method="post">
<input type="hidden" value="0" id="count" name="count">
<div name="family" id="family">
</div>
<input type="button" value="add" onCLick="jsAdd()">
<BR><br><input type="submit">
</form>
</body>
</html>

______________________________________________

Submit.jsp
______________________________________________

<html>
<head>
</head>
<body >
<table>
<tr><td>Relation Ship</td><td>NAME</td><td>Age</td></tr>

<%
int count=Integer.parseInt(""+request.getParameter("count"));
for(int i=0; i<count;i++){%>
<tr><td><%=request.getParameter("rel"+i)%></td><td><%=request.getParameter("name"+i)%></td>
<td><%=request.getParameter("age"+i)%></td></tr>
<% } %>
</table>
</body>

</html>