Solved

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

Posted on 2014-07-23
3
113 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

749 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