Q:

Update hidden field - jquery

OK, going to try and explain this properly as I think thats why an answer is escaping me and some users are giving me negative replies as they think I have not tried with research to solve this problem.
I have a page where a user is presented with images within a slide viewer. Each item in the slide viewer is inside a LI element. 
When a user chooses a slide, and the form is then submitted, I need the script to update a hidden field so I can take which slide they have chosen into a form. Either by updating onclick or when the form is submitted, it matters not when. The hidden field contains the URL of the image shown at that time.
So, the code I currently have is:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="/js/jquery.easing.1.3.js" type="text/javascript"></script>

<!-- this is the slideviewer code -->
<script src="/js/jquery.slideviewer.1.2.js" type="text/javascript"></script>

<!-- this is what I have been trying to update the hidden field -->
<script type="text/javascript">
$(document).ready(function(){
 $( "#wl_add" ).submit( function ( event ) { /* form name and id = wl_add */
 $('input[name="item_pic_url"]').val($('#mygalthree img').attr('src'));
 } );
});
</script>

<!-- the div containing the slide viewer -->
<div id="mygalthree" class="svw"><ul>
<?PHP

foreach($html->find('img') as $e){ // from simple_html_dom

    $image = $e->src;

    echo '<li><img src="'.$image.'" width=300 alt="" /></li>';

}

// the hidden field to be updated - i am presuming needs to be after the loop which feeds the LI elements
echo '<input type="hidden" name="item_pic_url" value="'.$image.'" />';

?>

</ul></div>

Or, would it be easier to update the hidden field each time a slide is chosen? below you can see the code for the slideviewer - I would have thought I might be able to add 

$('input[name="item_pic_url"]').val($('#mygalthree img').attr('src')); 

when the user clicks? But I cannot find where to add this either and I have tried nearly every line! Slideviewer code:
    jQuery(function(){
   jQuery("div.svw").prepend("<img src='/images/spinner.gif' class='ldrgif' alt='loading...'/ >"); 
});
var j = 0;
var quantofamo = 0;
jQuery.fn.slideView = function(settings) {
    settings = jQuery.extend({
        easeFunc: "easeInOutExpo",
        easeTime: 750,
        uiBefore: false,
        toolTip: false,
        ttOpacity: 0.9
    }, settings);
    return this.each(function(){
        var container = jQuery(this);
        container.find("img.ldrgif").remove();
        container.removeClass("svw").addClass("stripViewer");       
        var pictWidth = container.find("img").width();
        var pictHeight = container.find("img").height();
        var pictEls = container.find("li").size();
        var stripViewerWidth = pictWidth*pictEls;
        container.find("ul").css("width" , stripViewerWidth);
        container.css("width" , pictWidth);
        container.css("height" , pictHeight);
        container.each(function(i) {
    (!settings.uiBefore) ? jQuery(this).after("<div class='stripTransmitter' id='stripTransmitter" + (j) + "'><ul><\/ul><\/div>") : jQuery(this).before("<div class='stripTransmitter' id='stripTransmitter" + (j) + "'><ul><\/ul><\/div>");            
        jQuery(this).find("li").each(function(n) {
        jQuery("div#stripTransmitter" + j + " ul").append("<li><a title='" + jQuery(this).find("img").attr("alt") + "' href='#'>"+(n+1)+"<\/a><\/li>");                                             
        });
        jQuery("div#stripTransmitter" + j + " a").each(function(z) {
        jQuery(this).bind("click", function(){  
        jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current"); // wow!
        var cnt = -(pictWidth*z);
        container.find("ul").animate({ left: cnt}, settings.easeTime, settings.easeFunc);
        return false;
        });
        });

        container.bind("click", function(e){
            var ui = (!settings.uiBefore) ? jQuery(this).next().find("a.current") : jQuery(this).prev().find("a.current");
            var bTotal = parseFloat(jQuery(this).css('borderLeftWidth').replace("px", "")) +  parseFloat(jQuery(this).css('borderRightWidth').replace("px", ""));
            var dOs = jQuery(this).offset();
            var zeroLeft = (bTotal/2 + pictWidth) - (e.pageX - dOs.left);

            if(zeroLeft >= pictWidth/2) { 
                var uiprev = ui.parent().prev().find("a");  
                (jQuery(uiprev).length != 0)? uiprev.trigger("click") : ui.parent().parent().find("a:last").trigger("click");                           
            } 
            else {
                var uinext = ui.parent().next().find("a");
              (jQuery(uinext).length != 0)? uinext.trigger("click") : ui.parent().parent().find("a:first").trigger("click");
            }
        });

        jQuery("div#stripTransmitter" + j).css("width" , pictWidth);
        jQuery("div#stripTransmitter" + j + " a:first").addClass("current");
        jQuery('body').append('<div class="tooltip" style="display:none;"><\/div>');

        if(settings.toolTip){
        var aref = jQuery("div#stripTransmitter" + j + " a");

        aref.live('mousemove', function(e) {
        var att = jQuery(this).attr('title');
        posX=e.pageX+10;
        posY=e.pageY+10;
        jQuery('.tooltip').html(att).css({'position': 'absolute', 'top': posY+'px', 'left': posX+'px', 'display': 'block', 'opacity': settings.ttOpacity});
        });
        aref.live('mouseout', function() {
        jQuery('.tooltip').hide();
        });             
        }
        });
        j++;
    }); 
};

A:

OK, this has been driving me insane, but it is now solved... In the actual slideviewer code, when a user chooses a number of an image, I added a simple onclick to write the value of the hidden field.
jQuery("div#stripTransmitter" + j + " ul").append("<li><a title='" + jQuery(this).find("img").attr("alt") + "' href='#' onClick=\"document.wl_add.item_pic_url.value='" + jQuery(this).find("img").attr("src") + "'\" >"+(n+1)+"<\/a><\/li>");

Thanks for suggestions.

