This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line!
See this thread for details.
Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Javascript DOM and tapestry 5

 
Greenhorn
Posts: 2
  • 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
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • 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
  • 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.
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic