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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:09:30+00:00 2026-05-26T07:09:30+00:00

When i click on the link which has the id bob i want it

  • 0

When i click on the link which has the id bob i want it to close the chat but also give the value of the hidden input shown below.

<div id="chat" class="chat">
    <div id="ch" class="ch"> 
        <label id="name1">bob</label>
        <a id="bob" onclick="closechat(this.id)">x</a>  <--- LINK I CLICK ON 
    </div>
    <input type="hidden" name="to" id="to" value="bob">  <-- HIDDEN VALUE I WANT 
    <input type="hidden" id="chatboxid" value="chatbox"> 
    <div class="chatbox" id="chatbox" style="display: none; "> 
        <div class="messages"></div>
        <textarea name="message" id="message" class="chatinp" rows="3" cols="27">
        </textarea>
        <button class="send" onclick="submitmessage()">Send</button>
    </div>
</div>

the link i click gives me a id which is the id of a user and then it will close that chatbox
but i need the hidden value as it stores the value of a needed id so i can use JQUERY
to close it.

oh and this gets clones so the elements ids keep on changing everytime i clone it.

  • 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-26T07:09:30+00:00Added an answer on May 26, 2026 at 7:09 am

    Assuming that the id attribute on <a id="bob"> is unique, then you could do this inside your closechat function:

    function closechat(id) {
        var value_you_want = $('#' + id).closest('.chat').find('input[name=to]').val();
        //...
    }
    

    Pay attention to Jared’s comment though, if you are duplicating id attributes (as your HTML implies) then you’re begging the world to bury you in strange difficult to reproduce bugs: id attributes must be unique within each page. Also, using onclick attributes is pretty old school. Your HTML would be better off looking like this:

    <div class="chat">
        <div class="ch"> 
            <label>bob</label>
            <a class="closechat">x</a>  <--- LINK I CLICK ON 
        </div>
        <input type="hidden" name="to" value="bob">  <-- HIDDEN VALUE I WANT 
        <div class="chatbox" style="display: none; "> 
            <div class="messages"></div>
            <textarea name="message" class="chatinp" rows="3" cols="27">
            </textarea>
            <button class="send">Send</button>
        </div>
    </div>
    
    <script type="text/javascript">
        $('a.closechat').click(function() {
            // what closechat() does goes here and it should use
            // `this.id` instead of getting an argument.
        });
        $('button.send').click(function() {
            // What submitmessage() does goes here, it too looks at
            // `this` to to figure out where it is and which <textarea>
            // to use.
        });
    </script>
    

    References:

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

Sidebar

Related Questions

I use Javascript to click a link in the webbrowser control. But I don't
I'm showing a hidden box with jQuery on link-click. Now the box disappears when
I have some textboxes on a page and I want to click a link
When I click a link which calls following function...I get Something went wrong. We're
I have a form which has multiple input fields, and 3 main options. depending
I have a simple HTML file which has one link to a file kept
I want to create a page which has footer and some common parts. On
I am working on a page, which has a link which reads update. When
I have a link which has an onclick attribute, and there is a toggle
I am trying to click on a link in a webpage (which is always

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.