Hi,
I currently need to get a copy of selected text in a select list and copy it to a defined textbox. My current code is
<script type="text/javascript">
siteCopy = document.getElementById("customerfield_10200");
site = document.getElementById("customfield_10102");
site.onchange= function()
{
siteCopy.text=site.options[site.selectedIndex].text;
}
</script>
and it seemd doesn't work. Please be advised that siteCopy is a textbox custom field and site is a select list custom field.
Thanks.
The <textarea> element, as with most HTML form inupt elements, uses the `value` attribute to get and set its text. So you can change your code to this:
var siteCopy = document.getElementById("customerfield_10200"); var site = document.getElementById("customfield_10102"); site.onchange = function() { siteCopy.value=site.options[site.selectedIndex].value; }
and it should do what you want.
How are you getting this JavaScript loaded into the page? You probably need to wire it up so that the javascript only executes after the page has finished loading.
You can also use jQuery in JIRA to make selecting DOM elements a bit nicer.
Try something like this:
<script type="text/javascript> AJS.toInit(function() { var siteCopy = AJS.$("#customfield_10200"); var site = AJS.$("#customfield_10102"); site.change(function() { siteCopy.val(site.val()); }); }); </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
to be honest, I think this line has problem
siteCopy.val(site.val());
once I use it, I lose control to custom field, cannot add any other fields or delete any, I had to log into database and delete it manually.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<script type="text/javascript"> var siteCopy = document.getElementById("customerfield_10200"); var site = document.getElementById("customfield_10102"); site.onchange= function(){ siteCopy.value=site.options[site.selectedIndex].text; or $("customerfield_10200").val(site.options[site.selectedIndex].text); } </script>
i hope it should work if it is not let me know which version of jira using
Cheers,
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.