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.
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 ">
The code generated bettween the <div id="displaySend ">
looks like this....
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_idmess age" value="" />
And also pass the name ( luke ) into the actual input box...
<input type="text" class="searchMe ssageSend" id="searchbox" />
I have tryed for ages and the best jQuery i could come up with is below, but doesn't seem to work :( ....
please help.
My HTML is a form so someone can write and send a message. they can send the message to any name in my database.
Code:
<form method="post" name="postMessage" action="">
<textarea class="input" cols="50" rows="10"></textarea>
<input type="hidden" name="there_id" id="page_idmessage" value="" />
<label for="search">Send To:</label>
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 ">
Code:
<div id="searchBar">
<input type="text" class="searchMessageSend" id="searchbox" /><br />
<div id="displaysend">
</div>
</div>
</div>
looks like this....
Code:
<div style="position:relative;z-index:100000;"> <a href="#" class="click" id="24"> <div class="display_box" id="display_boxSearch"> <p id="searchName">Luke</p> </div> </a> </div>
And on-click pass the id value ( 24 ) into the value on this input field....
<input type="hidden" name="there_id" id="page_idmess age" value="" />
And also pass the name ( luke ) into the actual input box...
<input type="text" class="searchMe ssageSend" id="searchbox" />
I have tryed for ages and the best jQuery i could come up with is below, but doesn't seem to work :( ....
Code:
$(document).ready(function(){
$("a.click").click(function() {
var Id = $(this).attr("id");
var name = $(this).children(text);
$("#page_idmessage").val(Id);
$("#searchbox").val(name);
});
});
Comment