Solved

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

Posted on 2014-07-23
3
115 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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…

729 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