?
Solved

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

Posted on 2014-07-23
3
Medium Priority
?
116 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 2000 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

770 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