Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript:Retrive data from an array of textboxes with buttons

Status
Not open for further replies.

simbad003

Programmer
Nov 19, 2010
3
Hello am getting a big problem with the following codes.
while{
//looping fetching data from php
and putting them in a textbox

<input type="hidden" name="p[]"value="<?php echo $fetech['from php']?>"> //everything it works
<input type="button" name="send" onclick="doing();">
}

here comes the trouble i dnt know how to make it works to send the values to the other textboxe.

<script language="javascript">
function doing(){
var b= document.getElementsByName("p[]");
//sending the value to a textbox
//it works only if the "i" is being inputed manually
//example b[0] or b[1]
//below is the textbox
document.getElementById("al").value=b.value;
}
</script>
 
document.getElementsByName returns an array of all elements with the name "p[]".

Once that is done you need to specify an index in the array to access specific textbox. like b[1] or b[5] etc...

What is it you want to do? Send all textbox values over to the element with the ID o "al" as a string? as an array?

What exactly?



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
what i wanted is getting the index automatically ...example on cliking on the button it get the index of the array that is the , then i can use it

var i=document....

texbox=b.value;

because manually being inputed 0,1,2...
it will works

i cant use a for loop
for(var i=0;i<b.length;i++)
{
//
}
how can i do it when clicking of the button it already know the index of the array?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top