Jump to content

Adding text box "value' to add row


piznac

Recommended Posts

Ken,

Ok,..

With this javascript which we looked at yesterday:

[code] var cellRight = row.insertCell(1);
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'rm[]';
  el.id = 'rm' + iteration;
  el.size = 20; [/code]

Is there a way to add the value of the text box? i.e. If the first set of text boxes, and the first text box intial value was "<?php echo $row_ptopdalisting['rm']; ?>"

is there a way to duplicate that value when the user presses add row button?

I tried this:

[code] var cellRight = row.insertCell(1);
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'rm[]';
  el.id = 'rm' + iteration;
  el.size = 20;
  el.value = '<?php echo $row_ptopdalisting['rm']; ?>' [/code]

And the entire row does not repeat. Or the text boxes do not display.

I also tried to add this script:

[code]<script language="JavaScript" type="text/javascript">
function autofill(){
var fieldvalue = document.getElementById('rm').value;

//define all of the fields that will be changed
var autofillfield = new Array()
autofillfield[0] = "rm1"

for(var i = 0; i <autofillfield.length; i++){
document.getElementById(autofillfield[i]).value = fieldvalue;
}
}
</script>[/code]

And I couldnt get it to work. Any insight on this one.

Now I know this is probably not PHP related and should be posted in the JS section. But this is where you have helped me before & I was hoping to catch you again.
Link to comment
https://forums.phpfreaks.com/topic/9065-adding-text-box-value-to-add-row/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.