Hi
I have the below java script to display a custom field based on other field.
<script type="text/javascript">
status = document.getElementById('customfield_10473FieldArea');
target = document.getElementById('customfield_10521FieldArea');
// Hide the target field by default
target.style.display = 'none';
status.onchange=function() {
alert(status.value);
if (this.value != "*Doesn't*") {
target.style.display = '';
} else {
target.style.display='none';
}
};
</script>
By default the custom field is hidden but not sure why the function onchange is not getting invoked and the custom field 10521 is not getting enabled on the value change.
what type of this filed , is it cascade or select ?
field = document.getElementById('customfield_10473');
also refer this http://confluence.atlassian.com/display/JIRACOM/Using+JavaScript+to+Set+Custom+Field+Values
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also what i nticed was when i did view source the java script is in div tags.
Not sure if they need to be part of div tags
<input type="text"
name="customfield_10521
value=""
id="customfield_10521"
class="textfield"
/>
<div class="fieldDescription"><script type="text/javascript">
field = document.getElementById('customfield_10473');
if (field) {
target = document.getElementById('customfield_10521FieldArea');
// Hide the target field if field isn't "Yes"
if (field.value != '*Doesnât*') target.style.display='none';
field.onchange=function() {
if (this.value != '*Doesnât*') {
target.style.display = 'none';
} else {
target.style.display='';
}
}
}
</script></div>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Have changed the id's but still doesn't seem to work.
Can you please advise
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
Have changed the var status as below.
status = document.getElementById('customfield_10473');
Not sure whats wrong with the id's
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The ids are wrong. The FieldArea itself will not change, just the input element within it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.