0

So I'm using jquery to detect the change in an ID element in my form, like this:

$(document).ready(function(){
    $('#ID_a').change(function(){
        if(<<<some condition>>>){
            $('#ID_a').append(<<<more info>>>)
        }
    })
});

But I'm finding my site visitors aren't seeing the appended content because they aren't clicking off of the ID element because it's the last field in my form. They are just clicking the submit button. What can I do to help them see the appended content, which are new fields requesting additional info on the form? (Aside from completely redesigning my form)

1
  • Can you post the HTML including the '#ID_a' element? Commented Jan 26, 2012 at 21:29

3 Answers 3

2

You could use one of the key events (such as keypress or keydown) to show the fields as soon as they type anything.

Sign up to request clarification or add additional context in comments.

Comments

0

One option you could use is focus for an input field, so if they start typing in data, you could append the content.

Comments

0

Add a .submit event to the form:

$(document).ready(function() {
  var appendedText = false;

  function appendFormContent( elem ) {
     elem.append('some text');
     appendedText = true;
  }

  $('#the-form').submit(function() {
    if( !appendedText ) { 
      // content not appended
      appendFormContent( $('#some-id') );
      return false;
     }
  });

  $('#some-option').change(function() {
    appendFormContent( $('#some-id') );
  });

});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.