How to get the javascript objects in html body tag
Please support our JavaScript / DHTML / AJAX advertiser: Programming Forums
![]() |
•
•
Posts: 14
Reputation:
Solved Threads: 0
hi Foo,
Just read the code and give me a solution.My question will be after the code...
<html>
<head>
<title> working with jscript</title>
<script>
function appendtable()
{
var parent = document.getElementById("divide");
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 oOption = document.createElement("option");
var t = document.createTextNode("Ferrari");
oOption.setAttribute("value", 0);
oOption.appendChild(t);
oSelect.appendChild(oOption);
var oOption1 = document.createElement("option");
var t = document.createTextNode("Fessari");
oOption1.setAttribute("value", 1);
oOption1.appendChild(t);
oSelect.appendChild(oOption1);
oSelect.onchange=function() {txtChange(this,pname,price);}
var pname=document.createElement("input");
pname.type="text";
pname.value="product name"
var price=document.createElement("input");
price.type="text";
price.value="product price"
var qty=document.createElement("input");
qty.type="text";
qty.value="product quantity"
var sku=document.createElement("input");
sku.type="text";
sku.value="product SKU"
var upc=document.createElement("input");
upc.type="text";
upc.value="product UPC"
td.appendChild(oSelect);
td.appendChild(pname);
td.appendChild(price);
td.appendChild(qty);
td.appendChild(sku);
td.appendChild(upc);
}
function txtChange(obj,pname,price)
{
alert(obj.selectedIndex+" "+obj[obj.selectedIndex].text)
var elt=obj[obj.selectedIndex].text
return obj;
}
</script>
</head>
<body bgcolor=white>
<FORM ACTION=DList.html METHOD=POST>
Purchase Order ID <input type="text" name="poId"><br>
Sendor Address <input type="text" name="senderAddress"><br>
Vendor Address <input type="text" name="vendorAddress"><br>
poStatus <input type="text" name="poStatus"><br>
poDate <input type="text" name="poDate"><br>
expDate <input type="text" name="expDate"><br><br>
<h4> Product Details</h4>
<input type="button" onclick="appendtable()" value="Add Product">
<div id="divide"></div>
<input type="hidden" name=pId value=elt>
<input type="hidden" name=pName value= pname.value >
<input type="hidden" name=price value=price.value>
<input type="hidden" name=pQty value=qty.value>
<input type="hidden" name=SKU value=sku.value>
<input type="hidden" name=UPC value=upc.value>
<br> <input type="submit" name="btnSubmit" value="Submit Order">
</form>
</body>
</html>
in my <body> tag how can i get the pname value,qty value which is built by dhtml
thanks in advance
nandoo
Plz its really Urgent
i m trying hard in each and every step but still i m not able to finish bcoz of less xperience in web developing plz
Just read the code and give me a solution.My question will be after the code...
<html>
<head>
<title> working with jscript</title>
<script>
function appendtable()
{
var parent = document.getElementById("divide");
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 oOption = document.createElement("option");
var t = document.createTextNode("Ferrari");
oOption.setAttribute("value", 0);
oOption.appendChild(t);
oSelect.appendChild(oOption);
var oOption1 = document.createElement("option");
var t = document.createTextNode("Fessari");
oOption1.setAttribute("value", 1);
oOption1.appendChild(t);
oSelect.appendChild(oOption1);
oSelect.onchange=function() {txtChange(this,pname,price);}
var pname=document.createElement("input");
pname.type="text";
pname.value="product name"
var price=document.createElement("input");
price.type="text";
price.value="product price"
var qty=document.createElement("input");
qty.type="text";
qty.value="product quantity"
var sku=document.createElement("input");
sku.type="text";
sku.value="product SKU"
var upc=document.createElement("input");
upc.type="text";
upc.value="product UPC"
td.appendChild(oSelect);
td.appendChild(pname);
td.appendChild(price);
td.appendChild(qty);
td.appendChild(sku);
td.appendChild(upc);
}
function txtChange(obj,pname,price)
{
alert(obj.selectedIndex+" "+obj[obj.selectedIndex].text)
var elt=obj[obj.selectedIndex].text
return obj;
}
</script>
</head>
<body bgcolor=white>
<FORM ACTION=DList.html METHOD=POST>
Purchase Order ID <input type="text" name="poId"><br>
Sendor Address <input type="text" name="senderAddress"><br>
Vendor Address <input type="text" name="vendorAddress"><br>
poStatus <input type="text" name="poStatus"><br>
poDate <input type="text" name="poDate"><br>
expDate <input type="text" name="expDate"><br><br>
<h4> Product Details</h4>
<input type="button" onclick="appendtable()" value="Add Product">
<div id="divide"></div>
<input type="hidden" name=pId value=elt>
<input type="hidden" name=pName value= pname.value >
<input type="hidden" name=price value=price.value>
<input type="hidden" name=pQty value=qty.value>
<input type="hidden" name=SKU value=sku.value>
<input type="hidden" name=UPC value=upc.value>
<br> <input type="submit" name="btnSubmit" value="Submit Order">
</form>
</body>
</html>
in my <body> tag how can i get the pname value,qty value which is built by dhtml
thanks in advance
nandoo
Plz its really Urgent
i m trying hard in each and every step but still i m not able to finish bcoz of less xperience in web developing plz
•
•
Posts: 1
Reputation:
Solved Threads: 0
hi nandoo;
i written similar code ( copied u r code ) this is the solution check i
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="./test1.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>
/**************************************/*********************************/
start other jsp test1.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>
/************************** END**********************************/
i written similar code ( copied u r code ) this is the solution check i
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="./test1.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>
/**************************************/*********************************/
start other jsp test1.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>
/************************** END**********************************/
![]() |
Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
- can I get a title from an html header tag? (PHP)
- Generating clientside javascript (ASP)
- How to fix an image outside the <body> tag? (HTML and CSS)
- Dreamweaver and the missing html end tag (HTML and CSS)
- Urgent.....Dynamic Changes.... (JavaScript / DHTML / AJAX)
- Accessing JavaScript objects in the Body Tag (JSP)
- Accessing DOM Objects (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Password protect code
- Next Thread: How do I set linked Office files to open with full toolbar functionality?
•
•
•
•
Views: 44753 | Replies: 1 | Currently Viewing: 1 (0 members and 1 guests)





Linear Mode