Solved

how do you pass the id of a list item into a hidden field?

Posted on 2014-07-23
3
111 Views
Last Modified: 2014-07-24
Hi I have part of a function that I can't get to work.

I am trying to populate the value of a hidden field with the id of a list item.

Here is what I have so far.

Thanks,
<script>
$(document).ready(function() { 
$("#contact_nav ul li").click(function() {
 $("#contact_nav ul li").val("recipientId");

});
});
</script>


<div id="contact_nav" class="contact_nav" style="width:685px;">
	<ul style="width:685px;">
    	<li id="referenceID=6"><a href="#general">General Information</a></li>
    	<li id="referenceID=7"><a href="#member">Member Services</a></li>
    	<li id="referenceID=8"><a href="#patient">Patient Safety</a></li>
        <li id="referenceID=10"><a href="#press">Press Inquiries</a></li>
        <li id="referenceID=1"><a href="#web">Website Feedback</a></li>
    </ul>
    </div>

<input type="hidden" id="recipientId" name="recipientId" value="" /> 

Open in new window

0
Comment
Question by:smfmetro10
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40215645
Using : http://jsfiddle.net/2LtMv/1/

$(document).ready(function() { 
    $("#contact_nav ul li").click(function() {
        var v = $(this).attr("id");
        $("#recipientId").val(v);
    });
});

Open in new window

0
 

Author Closing Comment

by:smfmetro10
ID: 40217376
Thank you!! Just out of curiosity, why doesn't the value show up when you view source?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40218310
it would be too easy to see brother's password...
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question