Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7606379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:23:42+00:00 2026-05-31T00:23:42+00:00

I have some code where I have a button that I’d like to create

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:23:43+00:00Added an answer on May 31, 2026 at 12:23 am

    Which mess we have here! hehehehe

    So, first, why you don’t use .append(html) with each part of the html for the dialog? Second, when you want to concatenate strings in javascript, you must use + operator. And third, to prevent the defaul event action, use .preventDefault()

    Well, a quick fix in your code and we got this:

    $(document).ready(function() {
      var camerahash = '<?php echo $result_cameras[$i]["camera_hash"]; ?>';
      var $dialog = $('<div></div>');
      $dialog.append('<p>Please copy this key for setup:</p>')
             .append('<p><textarea id="textbox">' + apikey(camerahash) + '</textarea></p>')
             .append('<p>For more information see: <a href="http://www.myhost.com/forum/2-quickstart-docs">setup</a></p>');
      $dialog.dialog({
        autoOpen: false,
        title: 'Axis API Key'
      });
    
      $('#axis-details').click(function(e) {
        e.preventDefault();
        $dialog.dialog('open');
      });
    });
    

    Now, highlight texts inside textareas, or set any css properties, is not possible… To do it you’ll need an HTML element that accepts HTML content instead TEXT content, like a div, but it will not be editable. So, what you’ll really need is a textarea and a div to have an editable area with a preview area :]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my problem - I have some code like this: <mx:Canvas width=300 height=300> <mx:Button
I have some code to display a like button and this shows but with
so I have some code that looks like this: import java.awt.BorderLayout; import java.awt.Component; import
I have some code that dynamically creates a new button through JavaScript that when
I have some code like this in a winforms app I was writing to
I have some code like this: If key.Equals(search, StringComparison.OrdinalIgnoreCase) Then DoSomething() End If I
I have some code that create a few components on the click of a
my aspx (html) code is like below : this is first button (something that
I have some code below that creates a RelativeLayout and adds a button to
This makes no sense. I have some code that has a simple LinearLayout and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.