Jquery - Using the result of an Ajax call in a FORM hidden field
<p>I have a jquery script that uses Ajax to return data form a database. This works fine.</p>

<p>What I then would like to do is use the result in a hidden form field.</p>

<p>My Jquery:</p>

<pre><code>$(document).ready(function() { 
    function runrequests() { 
       $.ajax({ 
         url: 'get_request_id.php',
         type:"POST",
         data:"alertID",

         dataType: 'json',
            success: function(data){ 
            document.getElementById("alertid").innerHTML = data;
            } 
        });  
    };  

           // run it initially
    runrequests();

    // run it every 30 seconds
    setInterval(runrequests, 30 * 1000);
});
</code></pre>

<p>My Form:</p>

<pre><code>&lt;div id="alertid"&gt;&lt;/div&gt;
&lt;form id="form1" name="form1" method="post"&gt;
&lt;input type="image" src="butler_request.png" name="roominput" id="roominput" value="Submit" /&gt;
&lt;input type="hidden" name="MM_update" value="form1" /&gt;
&lt;input type="text" id="alertid" name="RecordID" value="value" /&gt;
&lt;/form&gt;
</code></pre>

<p>Can anyone help, many thanks for your time.</p>