473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How can i grab the id value using jQuery?

To explain i think I might be easier to show my code first...

My HTML is a form so someone can write and send a message. they can send the message to any name in my database.

Expand|Select|Wrap|Line Numbers
  1. <form method="post" name="postMessage" action="">
  2.  
  3. <textarea class="input" cols="50" rows="10"></textarea>
  4.  
  5. <input type="hidden" name="there_id" id="page_idmessage" value="" /> 
  6.  
  7. <label for="search">Send To:</label>
  8.  
  9.  
This code is straight after...

As the user types in the input text box, the names from the database all apear in a dropdown-box type list. These names appear between the <div id="displaySend">

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <div id="searchBar">
  4.     <input type="text" class="searchMessageSend" id="searchbox" /><br />
  5.  
  6. <div id="displaysend">
  7.  
  8.  
  9.               </div>
  10.            </div>   
  11.         </div>
  12.  
  13.  
  14.  
  15.  
The code generated bettween the <div id="displaySend">

looks like this....

Expand|Select|Wrap|Line Numbers
  1.  
  2. <div style="position:relative;z-index:100000;">
  3.  
  4. <a href="#" class="click" id="24">
  5.  
  6. <div class="display_box" id="display_boxSearch"> 
  7.  
  8. <p id="searchName">Luke</p>
  9.  
  10. </div>
  11.  
  12. </a>
  13.  
  14. </div>
  15.  
  16.  
I would like to click the <a class="click" id="24">

And on-click pass the id value ( 24 ) into the value on this input field....

<input type="hidden" name="there_id" id="page_idmessage" value="" />

And also pass the name ( luke ) into the actual input box...

<input type="text" class="searchMessageSend" id="searchbox" />

I have tryed for ages and the best jQuery i could come up with is below, but doesn't seem to work :( ....

Expand|Select|Wrap|Line Numbers
  1.  
  2. $(document).ready(function(){      
  3.  
  4.      $("a.click").click(function() {      
  5.  
  6.      var  Id = $(this).attr("id");
  7.      var  name = $(this).children(text);
  8.  
  9.      $("#page_idmessage").val(Id);
  10.      $("#searchbox").val(name);
  11.  
  12.  
  13.  
  14.      });    
  15.  
  16. });    
  17.  
  18.  
please help.
Mar 6 '12 #1

✓ answered by acoder

Any error messages?

PS. the ID should not be numerical.

1 1998
acoder
16,027 Expert Mod 8TB
Any error messages?

PS. the ID should not be numerical.
Mar 17 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
3
by: chrispragash | last post by:
Hello All, This may be a silly question to ask - but for some reason I am unable to get this to work! I have a server control that renders a Label and a linkbutton, and I have a Javascript...
2
by: darrel | last post by:
I'm still struggling to find a javascript/ajax library that I want to stick with for a while. JQuery is looking great these days...refined, LOTS of plug-ins, and an active community. Is...
10
rizwan6feb
by: rizwan6feb | last post by:
Hi I have created a tabbed interface using jQuery using the code below <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">...
4
by: pavanip | last post by:
Hi, I want to popup aspx page using jquery. I have written the following code <a href="Contactus.aspx?TB_iframe=true&height=250&width=200" class="thickbox" >AboutUs</a> I have called...
25
pradeepjain
by: pradeepjain | last post by:
<html> <head> <script src="jquery.js" type="text/javascript"></script> <script src="jquery.rating.js" type="text/javascript" language="javascript"></script> <link...
0
by: rhtdmrai | last post by:
I want to apply autocomplete in gridview (in asp.net3.5 with C#) using jquery and this gridview is within the ajax update panel <asp:UpdatePanel ID="UpdatePanel1" runat="server"> ...
1
by: krupapatel | last post by:
How can i pass querystring value in thickbox here is my code : Page 1 : <a href="tab1.html?keepThis=true&TB_iframe=true&height=500&width=1000&hotelid=<?php echo $hotelid; ?>"...
1
by: apssiva | last post by:
Hello All, 1. First i select the class name in combo box -> using jQuery reload the page. 2. after reload the page, Student name was display in random. so i add two radio button. 1....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.