Solved

ADD TEXT ,EVERY TIME THE BUTTON HITS

Posted on 2007-12-03
3
153 Views
Last Modified: 2010-04-01
hi,
I want to create button on jsp form, every time the user clicks the button an input of type text is added to the form, HOW I CAN DO THIS
IS IT A FUNCTION, because the onclick didn't call this function
<head>

<script>

var arrInput = new Array(0);

  var arrInputValue = new Array(0);
 

function addInput() {

  arrInput.push(arrInput.length);

  arrInputValue.push("");

  display();

}
 

function display() {

  document.getElementById('parah').innerHTML="";

  for (intI=0;intI<arrInput.length;intI++) {

    document.getElementById('parah').innerHTML+=createInput(arrInput[intI], arrInputValue[intI]);

  }

}
 

function saveValue(intId,strValue) {

  arrInputValue[intId]=strValue;

}  
 

function createInput(id,value) {

  return "<input type='text' id='test "+ id +"' onChange='javascript:saveValue("+ id +",this.value)' value='"+ 
 

value +"'><br>";

}
 

function deleteInput() {

  if (arrInput.length > 0) { 

     arrInput.pop(); 

     arrInputValue.pop();

  }

  display(); 

}

</script>

</head>

<body>

<form>

<input type="button" value="add item" onclick="addInput();" />

</form>

</body>

Open in new window

0
Comment
Question by:master_programmer
3 Comments
 
LVL 17

Accepted Solution

by:
gops1 earned 500 total points
ID: 20394736
You are missing this object inside your body

document.getElementById('parah')

where is parah?

Create this object:-> <div id="parah"></div>
0
 

Author Comment

by:master_programmer
ID: 20394782
hi,
it did not work , it generate error from statment( document.getElementById('parah'))
where exactly should I add this statment?
and where I have to put <div id="parah"></div>
show me this on my code?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20394792
Change

>>document.getElementById('parah').innerHTML="";

to

var elem = document.getElementById('parah');
alert(elem);
elem.innerHTML = "";

and tell us what you see
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now