Javascript - Function Parameter As Variable
<p>I've searched a bit for this answer, so here is what I'm trying to do - if possible</p>

<pre><code>function foo(variable){
</code></pre>

<p>If I call the function, how would I go about passing that parameter as a variable?</p>

<pre><code>function foo(9){
    var stuff = 9;

//then pass variable to rest of script
</code></pre>

<p>Here is the whole code:</p>

<pre><code>function ajaxgetter(variable) {
    var stuff = variable;
    var mygetrequest = new ajaxRequest();
    mygetrequest.onreadystatechange = function() {
        if (mygetrequest.readyState == 4){
            if (mygetrequest.status == 200 || window.location.href.indexOf("http") == -1){
                document.getElementById("result").innerHTML = mygetrequest.responseText;
            } else {
                alert("An error has occured making the request");
            }
        }
    }

    var namevalue = encodeURIComponent(document.getElementById("name9"+stuff).value);
    var agevalue = encodeURIComponent(document.getElementById("age9"+stuff).value);
    var utvalue = encodeURIComponent(document.getElementById("ut9"+stuff).value);
    document.getElementById("result").innerHTML = "&lt;center&gt;&lt;b&gt;Loading...&lt;/b&gt;&lt;/center&gt;&lt;br&gt;&lt;center&gt;&lt;img src='images/ajax-loader1.gif' /&gt;&lt;/center&gt;";
    mygetrequest.open("GET", "newdealerfinder.php?location="+namevalue+"&amp;distance="+agevalue+"&amp;ut="+utvalue1"&amp;r="+ Math.random(), true)mygetrequest.send(null);
}
</code></pre>

<p>Onclick event (PHP):</p>

<pre><code>$javacounter = 1;
if($miles1 &gt; 2) {
                echo "&lt;form action='' method='get' /&gt;
                &lt;input type='hidden' value='$city-&gt;lat,$city-&gt;lng' id='name9$javacounter' name='name9$javacounter' /&gt;
                &lt;input type='hidden' value='$currentunixtime' id='ut9$javacounter' name='ut9$javacounter' /&gt;
                &lt;input type='hidden' value='$distance' id='age9$javacounter' name='age9$javacounter' /&gt;
                &lt;input type='button' value='Coming Soon' onClick='ajaxgetter($javacounter)' /&gt;
                &lt;/form&gt;";
                $javacounter++;
            }
</code></pre>

<p>Location of script:
<a href="http://trucktiresearch.com" rel="nofollow">Here</a></p>
