Jump to content

Archived

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

piznac

Adding text box "value' to add row

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.

Share this post


Link to post
Share on other sites
Ok,..I guess this was moved and the title changed. And now it doesnt make much sense. The first srcipt is a "add row" script. Hope this helps

Share this post


Link to post
Share on other sites

×

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.