File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript DOM and tapestry 5

 
carlos smythe
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
carlos smythe
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic