title: How to run javascript in href?
body: <p>I'm trying to get a string of script to run in an href so the link will redirect users depending on an if/else statement.  My code:</p>
  
  <pre><code> &lt;div id="editredirect"&gt;
  &lt;script&gt;
      if("[@authfield:Authentications_2_Region]" == "[@field:Location_2_Region_ID]"){
      window.location.href = "member-details-edit?CID=[@field:Member_Caspio_ID]&amp;amp;Location_ID=[@field:Member_Location_ID]";
      }
      else if ("[@authfield:Authentications_2_Region]") == "[@field:Location_2_B_Region_ID]"{
      window.location.href = "member-details-edit?CID=[@field:Member_Caspio_ID]&amp;amp;Location_ID=[@field:Member_Location_ID]";
      }
      else {
      window.location.href = "member-details?CID=[@field:Member_Caspio_ID]&amp;amp;Location_ID=[@field:Member_Location_ID]";
      }
  &lt;/script&gt;
  &lt;/div&gt;
  
  &lt;style type="text/css"&gt;a.ex1:hover {color: #f18c21; text-decoration: underline;}
  &lt;/style&gt;
  
  &lt;a class="ex1" href="javascript:.initialize(document.getElementById("editredirect"));"&gt;Details&lt;/a&gt;
  </code></pre>
  
  <p>I've tred do also do a function like this:</p>
  
  <pre><code> &lt;script&gt;
      function editredirect {
      if("[@authfield:Authentications_2_Region]" == "[@field:Location_2_Region_ID]"){
      window.location.href = "member-details-edit?CID=[@field:Member_Caspio_ID]&amp;amp;Location_ID=[@field:Member_Location_ID]";
      }
      else if ("[@authfield:Authentications_2_Region]") == "[@field:Location_2_B_Region_ID]"{
      window.location.href = "member-details-edit?CID=[@field:Member_Caspio_ID]&amp;amp;Location_ID=[@field:Member_Location_ID]";
      }
      else {
      window.location.href = "member-details?CID=[@field:Member_Caspio_ID]&amp;amp;Location_ID=[@field:Member_Location_ID]";
      }
      }
  &lt;/script&gt;
  
  &lt;style type="text/css"&gt;a.ex1:hover {color: #f18c21; text-decoration: underline;}
  &lt;/style&gt;
  
  &lt;a class="ex1" href="javascript:editredirect"&gt;Details&lt;/a&gt; 
  </code></pre>
  
  <p>Neither one will work.  The first string returns a syntax error, the second tells me that "editredirect" is undefined.</p>
  
  <p>Thank you!</p>
  
  <p><strong><em>EDIT</em></strong></p>
  
  <p>Praveen Kumar's suggestions were the best.  The developer for the database I am using was able to get the application to do it without having to insert any script.  However, they did say that the event listener would have also worked once I had my parameters correct.</p>