dominic600 Posted September 14, 2011 Share Posted September 14, 2011 heres the line for my button echo "<tr><td colspan='2'><input type='submit' value='Add Reply' onClick=\"window.location = post_reply.php?cid=".$cid."&tid=".$tid."\" /><hr /> "; for some reason when i click on it in the site it does not do anything, but when i type the link in maunaly that the button should link to the page works. heres the code for the page that the button is on <?php require("top.php"); ?> <div id='content'> <div id='homepageright'> <?php require("scripts/connect.php"); if($username){ $cid = intval($_GET['cid']); $tid = intval($_GET['tid']); $sql = "SELECT * FROM topics WHERE category_id = $cid AND id = $tid"; $res = mysql_query($sql) or die(mysql_error()); /*$cid = $_GET['cid']; $tid = $_GET['tid']; $sql = "SELECT * FROM topics WHERE category_id='".$cid."' AND id='".$tid."'"; $res = mysql_query($sql) or die(mysql_error());*/ if(mysql_num_rows($res) == 1){ echo "<table width='100%'>"; if($username){ echo "<tr><td colspan='2'><input type='submit' value='Add Reply' onClick=\"window.location = post_reply.php?cid=".$cid."&tid=".$tid."\" /><hr /> "; } While ($row = mysql_fetch_assoc($res)) { $sql2 = "SELECT * FROM post WHERE category_id='".$cid."' AND topic_id= '".$tid."'"; $res2 = mysql_query($sql2) or die(mysql_error()); while ($row2 = mysql_fetch_assoc($res2)) { echo "<tr><td valign='top' style='border: 1px solid #000000;'><div style='min-height: 125px; '>".$row['topic_title']."<br /> by ".$row2['post_creator']." - ".$row2['post_date']. "<hr /> ".$row2['post_content']."</div></td><td width='200' valign='top' align='center' style='border: 1px solid #000000;'>User Info Here</td></tr><tr><td colspan='2'><hr /></td></tr>"; } echo "</table>"; } } else{ echo "This Topic Does Not Exist."; echo "$sql"; } } else{ echo "You Must Be Logged In To Continue."; } ?> </div> <div id='homepageleft'> <?php ?> </div> </html> </body> Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted September 14, 2011 Share Posted September 14, 2011 Have you done any debugging on your own? install firebug, chrome, or IE dev tools, and see what the console says about the error. I bet you have a concatenation problem or something else easily fixed. -Dan Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 14, 2011 Share Posted September 14, 2011 I believe you need a full url for windows.location. It is changing the URL in the browser and it would have no reference for the domain to use (unlike a normal link). Also it would be a good idea to enclose the value of window.location in quotes Try this (modifying the root url as needed) echo "<tr><td colspan='2'><input type='submit' value='Add Reply' onClick=\"window.location='http://www.mysite.com/post_reply.php?cid={$cid}&tid={$tid}\" /><hr />"; Quote Link to comment Share on other sites More sharing options...
dominic600 Posted September 14, 2011 Author Share Posted September 14, 2011 oh ok, well i put in the full url but when i click the button it doesnt go to a error or anything, like it wont go to another page at all Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 14, 2011 Share Posted September 14, 2011 I forgot a closing single quote right before the closing double quote. Double check the actual html created. It should look something like this: <input type='submit' value='Add Reply' onClick="window.location='http://www.yahoo.com'" /> Quote Link to comment Share on other sites More sharing options...
dominic600 Posted September 14, 2011 Author Share Posted September 14, 2011 alright, well i did that and its still not working, it seems like on of my quotes is off cause it just dont look right but when i randomly add a quote everything looks good. heres my line now. echo "<tr><td colspan='2'><input type='submit' value='Add Reply' onClick=\"window.location='http://www.trucksterusa.com/post_reply.php?cid={$cid}&tid={$tid}' /><hr />"; Quote Link to comment Share on other sites More sharing options...
dominic600 Posted September 14, 2011 Author Share Posted September 14, 2011 so i just tried to get rid of the onClick thing so i changed my line to cho "<tr><td colspan='2'><input type='submit' value='Add Reply' action='http://www.mysite.com/post_reply.php?cid={$cid}&tid={$tid}' /><hr />"; Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 14, 2011 Share Posted September 14, 2011 Now you removed the ending double quote for the onclick/action handler. You need to enclose the onclick/action value within double quotes. Then the value inside that in a javascript window.location with it's own value that should be in single quotes (not you can swap which ones use single vs double quotes. echo "<tr><td colspan='2'><input type='submit' value='Add Reply' onClick=\"window.location='[url=http://www.trucksterusa.com/post_reply.php?cid=]http://www.trucksterusa.com/post_reply.php?cid=[/url]{$cid}&tid={$tid}'\" /><hr />"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.