In issue edit screen, unable to get updated value of customfield using javascript.


I have added below javascript on textbox custom field's description.

setInterval(function(){console.log('value is:'+AJS.$("#customfield_11426\\:input1").val());  //unable to get updated value on each interval tick, it just prints initial value which is found while loading edit issue screen.

It executes on 2 sec but it just print same value of input1 textbox instead of updated values.

(just take the value which is found while loading issue edit screen but unable to get updated textbox values).

i need these updated value for further calculation.

Can you tell me what can be the cause and how to resolve .

Thank You

3 answers

try with 		
$('#customfield_11426').change(function() {  
  var val = $('#customfield_11426').val();



your code will execute on page load, to get latest value of the field you have to place your code inside some event

something like follows

$('#customfield_11426').bind('keypress', function (e) {
  //add your code here      

I have replaced and how it works -

when update the textbox valut to '157' then console.log prints '15' for AJS.$(this).val() and not 7. when give value - 1578 then shows 157. so, last char not cosndering and also, when do backspace to remove char then also it does not update value. any other event have to cosnider..?

also, when i show in "firebug" then it inspect the value as same value which is on loading the screen and no updated value.

Hi @dhaval soni ,

Change event will work correctly, where keypress, keydown,keyup are all keyboard events which will have some syncing issues, whatever you have discussed earlier is an keyboard value syncing issue,blur can also be used but when the field loses it's focus only - blur event will be called, Change is the correct event, whenever a value changes, this event will be called.So, Change event will work correctly for you.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in United States

Topic Tuesday: What's your favorite topic?

Good morning All, Our goal is to get you into the habit of while enjoying your favorite morning drink you are checking the NOVA "space" for topics and comments. Your input is really needed and...

50 views 4 0
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you