You are viewing limited content. For full access, please sign in.

Question

Question

Javascript does not execute

asked on July 8, 2014

 I'm trying to add any JavaScript to the form, but it does not execute. For example as provided by Insert Code Samples button on CSS and JavaScript page of the form:

q36 is a dropdown, q37 is a textbox

 

$("#q36").change(function(){
 alert("value changed");
});

$("#q37").click(function(){
 alert("value changed");
});

 

My final  goal is to fill a text box with text based on value selected in a dropdown list

Thank You

0 0

Answer

SELECTED ANSWER
replied on July 9, 2014

As Blake mentioned, you'll need to place your code inside a $(document).ready function so that it runs when the form loads.

 

As for filling a text box with the value selected in a drop-down list, you were on the right track!

 

When you're targeting input boxes, you'll need to use a selector like #q37 input instead of #q37, because the input element is actually a child of the #q37 element.

 

$(document).ready(function () {
    $('#q36').change(function () {
        $('#q37 input').val($('#q36 option:selected').val());
    });
});

 

0 0

Replies

replied on July 8, 2014

Do you have something like the following that contains the code you posted?

 

$(document).ready(function () {

});

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.