[jQuery] change method on hidden fields
Hi all!
I've been sizzling a little with the change method but I can't seem to get it to work.
I have two hidden fields that gets updated by numerous links and it works fine but the function I have tired to the onchange event is never fired. Here is some code snippets from my code:
$(function(){
// apply delegate to the onchange event of the hidden fields
$('#hdfLocation, #hdfType').change( function(){ alert("delegates is working");g_hdfChange = true; } )
}
<script type="text/javascript" defer="defer">
// global boolean that indicate if the hidden fields has been altered
var g_hdfChange = false;
function SetCalendarCallProperties(location, type)
{
// jQuery objects of the hidden fields "hdfLocation" and "hdfType"
var hdfLocation = $('#hdfLocation');
var hdfType = $('#hdfType');
// if the hidden field is not set (eg. first time this function is called)
// then show the periode picker.
if(!hdfLocation.val())
ShowPeriodePicker();
// if the new location and type ids are not the same as the previously one
// (they will never be in the first run)
// store the new location and type id in the hidden fields
if(hdfLocation.val() != location)
hdfLocation.val(location);
if(hdfType.val() != type)
hdfType.val(type);
if(g_hdfChange)
document.forms[0].submit();
}
...
<pre id="line109"><<span class="start-tag">input</span><span class="attribute-name"> type</span>
=<span class="attribute-value">"hidden" </span><span class="attribute-name">name</span>=<span class="attribute-value">"hdfLocation" </span><span class="attribute-name">id</span>=<span class="attribute-value">
"hdfLocation" </span><span class="attribute-name">value</span>=<span class="attribute-value">"5" </span><span class="attribute-name">/</span>>
<<span class="start-tag">input</span><span class="attribute-name">
type</span>=<span class="attribute-value">"hidden" </span><span class="attribute-name">name</span>=<span class="attribute-value">"hdfType" </span><span class="attribute-name">id</span>=<span class="attribute-value">
"hdfType" </span><span class="attribute-name">value</span>=<span class="attribute-value">"1" </span><span class="attribute-name">/</span>><span style="font-family: arial,sans-serif;">
...
<li>
<a class="club" href="#">NATTOGET (Slagelse)</a>
<ul>
<li id="li5dj"><a onclick="SetCalendarCallProperties(5, 1)" href="#">DJs</a></li>
<li id="li5show"><a onclick="SetCalendarCallProperties(5, 2)" href="#">Shows</a></li>
</ul>
</li>
<li>
<a class="club" href="#">RITZ (Køge)</a>
<ul>
<li id="li22dj"><a onclick="SetCalendarCallProperties(22, 1)" href="#">DJs</a></li>
<li id="li22show"><a onclick="SetCalendarCallProperties(22, 2)" href="#">Shows</a></li>
</ul>
</li>
Do the onchange event apply to hidden fields? I haven't found any documentation on that. Anyway I hope this issue is not too hard to crack.
Thanks in advance!
</span></pre>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/