1
owner_sel.onChange = function(){
    if(this.form.state_id.value ==  <%= $STATE_NEW %> ) {
        this.form.state_id.value = <%= $STATE_ASSIGNED %> ;
    }
}

I believe I'm calling the Perl variable wrong.

I currently have this code which checks if a select value is $STATE_NEW and if it is then switch it to $STATE_ASSIGNED but it is not working.

Can anyone tell me whats wrong with my call. Thanks

4
  • Can you view the javascript in your browser to see what values for those variables are output (I assume you're using some Perl templating library like Embperl, Template Toolkit...) Commented Jul 28, 2014 at 14:51
  • Maybe you wanna check it stackoverflow.com/questions/15578194/… Commented Jul 28, 2014 at 14:53
  • What does the generated Javascript look like? What templating system are you using in Perl? Commented Jul 28, 2014 at 14:57
  • 2
    FYI: you are generating JavaScript code in a template, and generally that's just a bad practice (you can no longer serve static minified Javascript files). Instead, write values into a data-* HTML attribute, and pull them out of the DOM: <div id="states" data-state-new="<%= $STATE_NEW %>" data-state-assigned="<%= $STATE_ASSIGNED %>"></div>, then with jQuery you can read these as easily as e.g. $('#states').data('state-new'). Commented Jul 28, 2014 at 15:13

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.