Solved

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
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 …
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now