I want to display textbox values. i have a for loop values, need to display that loop vales in textbox my codes are following:
<html>
<head>
<script>
function saveedit(id)
{
var str = 'txt'+id;
str = str.replace(/^\s+|\s+$/g,"");
var quote_send_id=document.getElementById(str).value;
}
</script>
</head>
<body>
<?php
for(i=0;i<=5;i++)
{
?>
<input type="text" name="txt" id="txt<?php echo $i; ?>" value="">
<?php
}
?>
<?php
for(i=0;i<=5;i++)
{
?>
<input type="button" name="txt" onclick="editfun(<?php echo $i; ?>);" value="">
<?php
}
?>
</body>
</html>
Your function name is wrong in the button
function saveedit(id) { var str = 'txt'+id; str = str.replace(/^\s+|\s+$/g,""); var quote_send_id=document.getElementById(str).value console.info(quote_send_id); }
<?php for($i=0;$i<=5;$i++) { ?> <input type="text" name="txt" id="txt<?php echo $i; ?>" value=""> <br/> <?php }
<?php for($i=0;$i<=5;$i++) { ?> <input type="button" name="txt" onclick="saveedit(<?php echo $i; ?>);" value=""> <br> <?php } ?>