Note that there are some explanatory texts on larger screens.

plurals
  1. PORe-directing to dynamic href in PHP script using JavaScript
    text
    copied!<p>I have a drop down user menu that contains child links that I cannot get to redirect properly. I unfortunately did not code the front-end, so I'm just trying to get it to link to dynamic PHP urls. I'm also working within the CodeIgniter framework, by the way. There are two clicks in the user's process (similar to Google's user icon). 1. You click the user image and drop down arrow, 2. You see profile, settings, logout. </p> <p>With the following script, clicking the drop-down arrow redirects to the first link, profile, without even doing the drop-down animation. Any thoughts?</p> <p>Here's the PHP file:</p> <pre><code>&lt;div class="user css3"&gt; &lt;a href="" class="css3"&gt; &lt;img src="images/user.jpg" alt="user" class="css3" /&gt; &lt;/a&gt; &lt;div class="child css3"&gt; &lt;ul class="user_links"&gt; &lt;li&gt;&lt;a href="&lt;?=base_url()?&gt;/profile/view/&lt;?=$userID?&gt;/myfeed"&gt;Profile&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="&lt;?=base_url()?&gt;/settings/"&gt;Settings&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="&lt;?=base_url()?&gt;/login/logout"&gt;Logout&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Here's the JavaScript for drop-down arrow button:</p> <pre><code>$('div.user').click(function() { $('div.user div.child').slideToggle("fast"); $('div.live div.action div.category div.child, div.live div.action div.sort div.child').slideUp(); return false; }); </code></pre> <p>Here's the JavaScript that I came up with for the <code>&lt;ul&gt;</code> (I'm not much of a JS dev. haha):</p> <pre><code>$('ul.user_links li a').click(function() { document.location($(this).attr("href")); }); </code></pre> <p>Any thoughts are greatly appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload