I have some code where I have a button that I'd like to create a dialog. This dialog will have a textarea in it with some populated data that will be highlighted. I can create the dialog and textarea I'm just not sure how to put the data into the text area and how to highlight it.
<button id="axis-details" onclick="apikey('<?php echo $result_cameras[$i]["camera_hash"]; ?>');">API Key</button>
function apikey(camerahash)
{
var $key = "http://myhost.com/notify.php/" +camerahash;
return $key;
}
$(document).ready(function() {
var $dialog = $('<div></div>')
.html('Please copy this key for setup: <p><textarea id=\"textbox\">'apikey(camerahash);'</textarea></p><p>For more information see: <a href=\"http://www.myhost.com/forum/2-quickstart-docs\">setup</a></p>')
.dialog({
autoOpen: false,
title: 'Axis API Key'
});
$('#axis-details').click(function() {
$dialog.dialog('open');
// prevent the default action, e.g., following a link
return false;
});
});
The behavior I want is when someone clicks the button a jquery ui dialog appears. That is easy enough. In the dialog I want a textarea, also easy. The part I can't figure out is that I want to put a constructed url inside that textarea (the $key variable). Plus that url needs to be highlighted. I can't figure out how to put that url inside the textarea and how to highlight it.
Thanks in advance.