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

Question

Question

Copy value to Input field placed in DIV

asked on September 3, 2015

Okay, so I'm trying to merge a couple of different posts here...  I have the Input field being placed in a DIV (Post Here) working great.  Also, I have the copy value from one field to another (Post Here) working correctly as well.  Now I am trying to combine the two, but value is not being copied over.  I am pretty sure I'm not pointing at the correct selector, but I have tried a number of times with different combinations with no results. I have tried the following in all different combinations: #q78 DIV.cf-field INPUT, #q78 DIV.cf-field SPAN, #q78 DIV.cf-field DIV

My code is below.  

Insert Field in DIV:

  var carrier = $('#carrier');//Carrier
  var txtCarrier = $('#q78 DIV.cf-field INPUT, #q78 DIV.cf-field SPAN');//Search for INPUT or SPAN, SPAN is used for display
  txtCarrier.remove(); //remove the textbox from its current location
  txtCarrier.insertAfter(carrier); //Insert it after the placeholder
  carrier.remove();//Remove the placeholder
  $('#q78').hide();//Hide the old label

Copy Value:

$('.company input').blur(function(){
  $('.company_sub input').val($(this).val());
  $('#q78 input').val($(this).val());

The idea here is to have the submitter fill out the 'Company' field on the first tab, then pass this information to the next tab where Company (q78) should be the same value.  This will eliminate the user from having to enter the same value multiple times.  

0 0

Answer

SELECTED ANSWER
replied on September 3, 2015 Show version history

Hello Nate, 

 

I was able to get the input in the Div to be the same by using the id that is given to the input in the DIV. Below are the steps to get the id of the input in the DIV.

 

Right click the input box and select Inspect element as shown below:

 

Look for the id of the input field, hovering over the code should highlight the corresponding element.

In this case, the id of my input element in the div is "Field4". So, the copy code becomes:

  $('.company input').blur(function() {
    $('.company_sub input').val($(this).val());
    $('#Field4').val($(this).val());
  });

(Note: I did this in Chrome, but the process should be similar for IE and Firefox to get the id.)

 

Hope this helps!

1 0

Replies

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

Sign in to reply to this post.