title: Trying to get value of hidden field using jquery
body: <p>I am trying to a value from a hidden field. </p>
  
  <p>Here is the HTML which is spit out by a Visualforce page (Salesforce) (The ids are dynamically generated )</p>
  
  <pre><code>&lt;div style="width:300px;position:relative" id="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:optableAccount"&gt;
  &lt;!--  Need value for below field to be alerted --&gt;
  &lt;input type="hidden" value="001i0000008LDtv" id="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lkid" name="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lkid"&gt;
  &lt;input type="hidden" value="Aethna Home Products" id="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lkold" name="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lkold"&gt;
  &lt;input type="hidden" value="001" id="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lktp" name="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lktp"&gt;
  &lt;input type="hidden" value="0" id="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lspf" name="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lspf"&gt;
  &lt;input type="hidden" value="0" id="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lspfsub" name="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lspfsub"&gt;
  &lt;input type="hidden" value="1" id="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_mod" name="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_mod"&gt;&lt;span class="lookupInput"&gt;
  &lt;!-- I do get the value of below field --&gt;
  &lt;input type="text" size="20" onchange="getElementByIdCS('massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lkid').value='';getElementByIdCS('massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_mod').value='1';" name="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup" maxlength="255" id="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup"&gt;
  &lt;script&gt;new ForeignKeyInputElement("massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup","/_ui/common/data/LookupValidationServlet",null,true,{"acent":"001"});&lt;/script&gt;&lt;a title="Account Name Lookup (New Window)" onclick="setLastMousePosition(event)" id="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lkwgt" href="javascript:%20openLookup%28%27%2F_ui%2Fcommon%2Fdata%2FLookupPage%3Flkfm%3DmassConvertwithInputs%253ApbmconvertInput%253ApbformmconvertInput%26lknm%3DmassConvertwithInputs%253ApbmconvertInput%253ApbformmconvertInput%253ApbsmconvertInput%253Apbspbtable%253A0%253AaccountLookup%26lktp%3D%27%20%2B%20getElementByIdCS%28%27massConvertwithInputs%3ApbmconvertInput%3ApbformmconvertInput%3ApbsmconvertInput%3Apbspbtable%3A0%3AaccountLookup_lktp%27%29.value%2C670%2C%271%27%2C%27%26lksrch%3D%27%20%2B%20escapeUTF%28getElementByIdCS%28%27massConvertwithInputs%3ApbmconvertInput%3ApbformmconvertInput%3ApbsmconvertInput%3Apbspbtable%3A0%3AaccountLookup%27%29.value.substring%280%2C%2080%29%29%29"&gt;&lt;img title="Account Name Lookup (New Window)" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onblur="this.className = 'lookupIcon';" class="lookupIcon" alt="Account Name Lookup (New Window)" src="/s.gif"&gt;&lt;/a&gt;&lt;/span&gt;&lt;select style="width:148px" size="1" class="accSelectandlookup" name="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:convertedStatus" id="massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:convertedStatus"&gt;  &lt;option value="000000000000000000"&gt;Create New Account: Greenwich Media&lt;/option&gt;
  &lt;/select&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Here is jquery code i am using the alert the values</p>
  
  <pre><code>&lt;script&gt;
  
  $(document).ready(function () {
  
  $('form :input[id$="accountLookup"]').change(function() {
       $('form :input[id$="accountLookup"]').each(function () {
              var str= $(this).attr("id") + "_lkid"; 
              alert($(str).val());// This alert shows undefined
              alert($(this).val());// This shows the Aethna Home Products which correct
              alert($('massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lkid').val());  // This shows undefined
  });  
  }); 
  $('form :input[id$="accountLookup"]').change(function() {
       $('form :input[id$="accountLookup_lkid"]').each(function () {
              alert($(this).val());  // This shows a blank value
  });  
  }); 
  });   
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I need to get the value of the field <code>massConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:accountLookup_lkid</code></p>
  
  <p>I have commented the jquery script with what each alert is throwing currently</p>
  
  <p>Any idea what i am doing wrong?</p>