944,030 Members | Top Members by Rank

Ad:
May 3rd, 2005
0

How to get the javascript objects in html body tag

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nandoo is offline Offline
14 posts
since Apr 2005
Aug 21st, 2007
0

Re: How to get the javascript objects in html body tag

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**********************************/
Reputation Points: 10
Solved Threads: 0
Newbie Poster
thebestB is offline Offline
1 posts
since Aug 2007
Jun 23rd, 2010
0
Re: How to get the javascript objects in html body tag
thank you for this nice post
it's relay helpful to me.
webdesign
Reputation Points: 10
Solved Threads: 0
Newbie Poster
zaggaustralia is offline Offline
1 posts
since Jun 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: help with YUI calendar and HTML dataset
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: XML flash embedding problems





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC