summaryrefslogtreecommitdiff
blob: 9558ec9e99a373221503cabad5702453b7502392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
window.appendFromSelect = function ( selectid, targetid ) {
	'use strict';

	var select, target, atxt;

	select = document.getElementById( selectid );
	target = document.getElementById( targetid );

	if ( !target || !select ) {
		return;
	}

	atxt = select.options[select.selectedIndex].value;

	if ( !atxt ) {
		return;
	}

	/* Ugly hack */

	target.value = target.value.replace( /default/, '' );

	if ( target.value.replace( /[\s\t\n]/ig, '' ) !== '' ) {
		atxt = ', ' + atxt;
	}
	target.value += atxt;
};