Accessing live value of a DOM element
<p>I have a hidden input that has a default value, which can be changed depending on the value of the selected radio button associated with it.</p>

<p>So, if I select the second radio button, the js_file_path hidden input will have its value changed to "/shared". Nice and easy, and I've got this to work fine. </p>

<p>My problem is when I try to get js_file_path's value via jQuery <code>$("#js_file_path").val()</code>, I always get the value of the hidden field when the page was loaded. How do I get its current value instead? I know of the live() handler and its purpose, but not quite sure how to make use of it in this context where I'm trying to pass "js_file_path"'s value as a function argument.</p>

<p>Any help is appreciated.</p>

<p>EDIT:</p>

<p>This is the code to detect the value of the file path has changed.</p>

<pre><code>&lt;input type="hidden" id="js_local_file_path" value="local"&gt;
&lt;input type="hidden" id="js_shared_file_path" value="shared"&gt;
&lt;input type="radio" name="js_type_for_file_upload" value="local" checked&gt;
&lt;input type="radio" name="js_type_for_file_upload" value="shared"&gt;
&lt;input type="hidden" id="js_file_path" value="local"&gt;

$("[name=js_type_for_file_upload]").live( "change", function(){
    switch( $(this).val() ){
        case "local":
            $("#js_file_path").val( $("#js_local_file_path").val() );
            // do other stuff
        break;
        case "shared": 
           $("#js_file_path").val( $("#js_shared_file_path").val() );
            // do other stuff
        break;
    }
});`
</code></pre>

<p>So, when I select the second radio button and check the DOM I can see that the js_file_path's value has been changed to "shared" correctly.</p>

<p>I then try to proceed and make a function call that includes the value of js_file_path as its argument when a button with an id "button" is clicked.</p>

<pre><code>$("#button").click( function(){ 
     a_name_of_a_function( $("#js_file_path").val() ); 
});
</code></pre>

<p>For debugging, I put an alert prompt inside a_name_of_a_function() to output its file_path's parameter's value.</p>

<pre><code>function a_name_of_a_function( file_path ){
    alert( file_path );
    // other stuff
}
</code></pre>

<p>Even if I've selected the "shared" radio button, the alert prompt will always displays "local".</p>
