passing variables assigned from input box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phub11
    New Member
    • Feb 2008
    • 127

    passing variables assigned from input box

    Hi all,

    I'm try to set up a hidden variable that takes the value of an input:

    Code:
    bFINALTEXT1 = document.createTextNode("Final:");
    bFINAL1 = document.createElement("input");
    bFINAL1.style.width="5em";
    bFINAL1.type="text"
    bFINAL1.name=compXY+'comp[]';
    //bFINAL1.onblur=function(){getfinal(this.value);};
    
    bMAX1 = document.createElement("input");
    bMAX1.type="hidden"
    bMAX1.name=compXY+'comp[]';
    //
    bMAX1.value=bFINAL1.value
    As you can see, I had originally been using a function (getfinal) which works fine if I don't dynamically add duplicate inputs that get different values. To solve this problem. I was hoping that I could just copy the X.value across, but it doesn't work.

    Any ideas?

    Thanks in advance
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    At the time you are assigning the value to the hidden input, the text input has no value. And the expression bMAX1.value=bFI NAL1.value doesn't provide a synchronise mechanism for run time.

    So you would have to do it when some event is fired. onchange can be a good choice.

    Code:
    a.onchange = function() {b.value = this.value;}
    I don't understand the purpose behind it, as at the end, you have two variables of same value, that can also be done at server end(?).

    Comment

    Working...