Have you considered using a jquery skinned drop-down list with country names and simply using the selected option to add the country code to your textbox?
UPDATE: It is actually a dropdown. Consider the jQuery TimePicker plugin snippet below:
// some default cars
var newHTML = '';
var $t = $(this);
// calculate the offsets
var height = this.height() + 1;
var width = this.outerWidth();
// generate our html dropdown
var timeMargins = ['00', '15', '30', '45'];
newHTML += ' <select style="position: absolute; left:0;top:' + height + 'px; width: ' + width + 'px;" size="7">'
for (var h = params.minHour; h <= params.maxHour; h++)
{
for (var i = 0; i < timeMargins.length; i++)
{
if (h == params.maxHour && timeMargins[i] >= params.maxMinute)
{
//do nothing
}
else
{
var newhour = "" + h;
var v = (newhour.length == 1 ? '0' : '') + h + ':' + timeMargins[i];
newHTML += '<option>' + v + '</option>';
}
}
}
newHTML += '</select>';
var id = this.attr('id');
var newid = id + '-container';
// wrap the target in the div
$t.wrap('<div id="' + newid + '" style="position: relative; display: inline;"></div>');
$t.after(newHTML);
It should help you understand how the dropdown is created via jQuery/javascript.