Automatically change JavaScript function value
<p>Here is my problem.. I have some JavaScript that I want to run, however I need it to be unique each time it gets inserted. I tried adding a variable to it that would change it, however it only changes it on the first call/display. Here is the script:</p>

<pre><code>     &lt;script type=\"text/javascript\"&gt;
                    function validate_f( )
                    {
                    var x=document.forms[\"fill\"][\"textfield\"].value
                    if (x==null || x==\"\")
                      {
                      alert(\"Field cannot be empty\");
                      return false;
                      }
                    }
                    &lt;/script&gt;
</code></pre>

<p>The actual form code is:</p>

<pre><code>                    echo "&lt;td width=\"10%\"&gt;
                &lt;form method=\"POST\"action=\"$actual_link\" id=\"fill\" onsubmit=\"return validate_f( );\"&gt;
                &lt;input type=\"hidden\" value=\"{$data['id']}\" name=\"id\"&gt;
                &lt;input type=\"text\" size=\"20\" class=\"BUTTON_INPUT\" name=\"url\" value=\"\" id=\"textfield\"&gt;
                &lt;/td&gt;
                &lt;td width=\"1%\"&gt;
                &lt;input type=\"Submit\" class=\"BUTTON_FILL\" name=\"fill\" value=\"\"&gt;
                &lt;/form&gt;
</code></pre>

<p>The problem is that form gets echoed multiple times with different links, but the script will only work the first time. So my only solution I could think of was to have the JavaScript echoed along with the form and have the function name changed on both the script &amp; the form.</p>

<p>I hope what I'm trying to do makes sense, so basically I need "function validate_f( )" &amp; "onsubmit=\"return validate_f( );\"" to change with each repeat/echo ..</p>
