Scipting Help

Hi everyone,

I'm having a problem with scripting and was hoping someone could help me. Is there a way to to give field a value of another field, but would only do that if a third
field's text was a certain text. So i'm trying to do something like this.

if ( edit1 == "Power" ) { edit2 == edit3.value;
}

I'm not sure if this is how you would do that but that what i got so far. Would that also have to be in its own function? Still kinda new at using Javascript so still learning. Any help would be appreciated. Thanks.

Comments

  • I think you are looking for something like this (assuming version 2 of the designer)
    function calcPower()
    {
       if (edit1.Text == 'Power')
       {
          edit2.Text = edit3.Text
       }
    }
    

    and then the field source would be:
    js:calcPower()
    
  • Yes it is Version 2 of the Designer. Still not working. I've put the field source in edit2 and it still does nothing and there are no scripting errors or anything like that. The viewer brings up the character sheet but that field is just blank. I've been working in this for like 2 weeks and its the last thing i need to figure out for my sheet. Any other suggestions?
  • Actually, my bad. I think what you want is
    function calcPower()
    {
       if (edit1.Text == 'Power')
       {
          return edit3.Text;
       }
       else
       {
          return '';
       }
    }
    
    When used as a field source, the function Is run and the result of the function is assigned as the text for the field.
  • Okay still not working, here I've attached an example to make sure I did it right.
  • It works after a small change. Change the names of the fields in the code to Edit1.Text and Edit3.Text since javascript is case sensitive.
  • Oh wow... I feel dumb. It worked. Thanks for the help.

Leave a Comment