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 3599360
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:21:29+00:00 2026-05-18T20:21:29+00:00

I have the following HTML code (which is placed within several files), which inserts

  • 0

I have the following HTML code (which is placed within several files), which inserts a selected/clicked smiley within a textarea:

<a href="javascript:insertTheSmiley(':)');void(0)"><img src="images/smile.gif" alt=":)" title=":)" /></a>

<!-- this is a link to open a popup listing all smilies (see smilies.html to see what it contains) -->
<a href="#" onClick="window.open('smilies.html', 'Smilies', 'width=250,height=500,scrollbars=1');">Show all smilies</a>

<textarea id="textarea" cols="60" rows="10" style="width: 100%"></textarea>

<a href="javascript:insertTheSmiley(':)');void(0)"><img src="images/smile.gif" alt=":)" title=":)" /></a>

<!-- this is a link to open a popup listing all smilies (see smilies.html to see what it contains) -->
<a href="#" onClick="window.open('smilies.html', 'Smilies', 'width=250,height=500,scrollbars=1');">Show all smilies</a>

<textarea id="textarea" cols="60" rows="10" style="width: 100%"></textarea>

The smilies.html contains the following HTML:

<a href="javascript:putTheSmiley(':)');void(0)"><img src="images/smile.gif" alt=":)" title=":)" /></a>

and the JavaScript functions used are:

<script>
function insertTheSmiley(input) {
document.getElementById('textarea').value += input;
}

function putTheSmiley(input) {
window.opener.insertTheSmiley(input);
}
</script>

What I’m intending for it to do is place the selected/clicked smiley in the appropriate textarea, currently (as an example scenario) if I click on the second smiley link (aswell as within the smilies.html) it places the smiley within the first textarea, however I want it to be placed within the second (which is what I consider the appropriate one) – this is just an example to illustrate my problem.

I’m guessing its an issue with the element id, is their some way to automate this or a workaround, as I’ve seen many forum software do this?

Heres a thought (which doesn’t seem to work):

<script>
function insertTheSmiley(input, id) {
global id;
document.getElementById(id).value += input;
}

function putTheSmiley(input) {
global id;
window.opener.insertTheSmiley(input, id);
}
</script>
  • 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-18T20:21:30+00:00Added an answer on May 18, 2026 at 8:21 pm

    First of all, give different ID to each textarea.. having both with the same ID is bad and wrong.

    Second, when calling the function pass the ID of the desired textarea:

    href="javascript:insertTheSmiley(':)', 'MySecondTextarea');void(0)"
    

    And finally in the function insertTheSmiley change the code to get the ID from the function parameters instead of the way it’s now – post the code of the function if you need help with this.

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

Sidebar

Related Questions

I have the following code which uses the WWW::Mechanize and HTML::TableExtract modules. Everything works
I have the following code which builds a JQueryUI Dialog popup. $j('<div></div>') .html(message) .dialog({
I have the following HTML code: <td> <input type=text size=40 value= name=related_image id=related_image> <input
I have the following code which attaches an image to the email but I
I have the following code which enables a button when the checkbox is checked.
I have the following code which loads a xml file to populate a dropdown.
Edit: I am using domPDF 0.5.1, hosted http://code.google.com/p/dompdf/ I am using HTML table to
I'm currently creating a very small form on my homepage using HTML and JavaScript.
I have a button named okbutton. A callback function is bind to the click
This is my first WordPress 3 site. I'm currently developing a site for a

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.