aspose file tools*
The moose likes Other Application Frameworks and the fly likes Javascript DOM and tapestry 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Javascript DOM and tapestry 5" Watch "Javascript DOM and tapestry 5" New topic
Author

Javascript DOM and tapestry 5

carlos smythe
Greenhorn

Joined: Dec 20, 2008
Posts: 2
Hello everybody!! im new on tapestry and i have a little question, how can i get the value of an input that was dynamically added into the form with javascript, i know that is easy to add inputs whit ajax but i realy think that its faster and better specially for tapestry type apps, so this is the html code, any suggestion?

-html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"_
-head_DOM-/head_
-script type="text/javascript"_
function addRecord(){
var count = document.getElementById("count");
var rows = document.getElementById("rows");
count.setAttribute("value", parseInt(count.value,0)+1);
var table = document.getElementById("content").tBodies[0];
var row = document.createElement("TR");

var cell1 = document.createElement("TD");
var nameBox = document.createElement("INPUT");
nameBox.setAttribute("type","TextField");
nameBox.setAttribute("name","nameBox" + count.value);

var button = document.createElement("a");
button.setAttribute('value','Delete');
button.innerHTML = count.value;
button.on click=function(){deleteRecord(this);}

cell1.appendChild(button);
cell1.appendChild(nameBox);

row.appendChild(cell1);
table.appendChild(row);

nameBox.focus();
}
function deleteRecord(button){
var row = button.parentNode.parentNode;
var table = document.getElementById('content').getElementsByTagName('tbody')[0];
table.removeChild(row);
}

-/script_
-body on Load="addRecord()"_
-input name="count" type="hidden" id="count" value="0" /_
-input name="rows" type="hidden" id="rows" value="" /_
-t:form t:id="myForm"_
-table id="content"_
-tr_
-td width="150" class="orillat"_Names-/td_
-/tr_
-/table_
-table_
-tr_
-td_
-input type="button" value="add row" on Click="addRecord()" /_
-input type="submit" on Click="rows.value=count.value, count.value="0" /_-/td_
-/td_
-/tr_
-/table_
-/t:form_
-/body_
-/html_

i apreciate any help
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Not that I can help, but please re-post you code into CODE tags. So that the code is readable and indented. There are buttons under the Add Reply button to do this. Look for the one called CODE.

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
carlos smythe
Greenhorn

Joined: Dec 20, 2008
Posts: 2
ok, i didnt see that button next time i post im going to use it, but right now Howard Lewis tells me how to do what i want to do. thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javascript DOM and tapestry 5