patsman77 Posted June 5, 2011 Share Posted June 5, 2011 Hello All, I have a code I am struggling and hoping someone can show me the error in my ways, This is from a form that posts the results to a database. Everything works except one thing. When I go back to the form, the focus is not the selection of what is in the database. Here is the code: <? $con3= mysql_connect("localhost","xxxxxxxx","xxxxxxx"); mysql_select_db("swammisp_football", $con3); $sql2="select * from signups WHERE Name='$_SESSION[user]' AND Fantasy='Yes'"; //echo "$sql2<br>"; $infantasy=mysql_query($sql2) or die (mysql_error()); mysql_select_db("swammisp_football", $con3); $sql="select qb from Fantasy WHERE User='$_SESSION[user]' AND Week=$week"; $result=mysql_query($sql); if (mysql_num_rows($infantasy) == 0){ echo "<option value=\"OUT\">Not in pool</option>"; } else{ $sql3="select qb from Fantasy WHERE user='$_SESSION[user]' AND Week=$week"; $result2 = mysql_query($sql3); if (mysql_num_rows($result2) == 0){ $pick = "XXX"; echo "<option value=\"BAD\" selected>PICK</option>"; } else { $sql=mysql_fetch_object($result2); $team = $sql->qb; } $sql="select Player from QB"; $result=mysql_query($sql); while ($sql = mysql_fetch_object($result)) { // echo $sql->vid . " (against " . $sql->hid . ")<BR>"; $qbout[$sql->Player] = "<option value=\"$sql->Player\"" . checkpick($sql->Player, $Player) . ">$sql->Player</option>"; } sort($qbout); foreach ($qbout as $team){ echo $team; } //mysql_free_result($result); } ?> So basically, when I bring the form back up, it brings up the list of players, which it should incase the user wants to change the player, but it does not focus to the player that the user has already chosen. Thanks for any help. Patsman77 Quote Link to comment https://forums.phpfreaks.com/topic/238485-bring-back-the-focus-item-to-form/ Share on other sites More sharing options...
sunfighter Posted June 5, 2011 Share Posted June 5, 2011 session_start(); // first thing we do is start sesions and I don't see that. Quote Link to comment https://forums.phpfreaks.com/topic/238485-bring-back-the-focus-item-to-form/#findComment-1225630 Share on other sites More sharing options...
Pikachu2000 Posted June 5, 2011 Share Posted June 5, 2011 This is a php issue, not MySQL. Moving thread to php help . . . Quote Link to comment https://forums.phpfreaks.com/topic/238485-bring-back-the-focus-item-to-form/#findComment-1225634 Share on other sites More sharing options...
xyph Posted June 5, 2011 Share Posted June 5, 2011 I think this is a JavaScript/DOM issue, not a PHP issue. Unless by focus you mean something completely different. Quote Link to comment https://forums.phpfreaks.com/topic/238485-bring-back-the-focus-item-to-form/#findComment-1225667 Share on other sites More sharing options...
Pikachu2000 Posted June 5, 2011 Share Posted June 5, 2011 There's no JS in it. I'm kinda thinking the OP may be referring to making the <select> field sticky. Quote Link to comment https://forums.phpfreaks.com/topic/238485-bring-back-the-focus-item-to-form/#findComment-1225674 Share on other sites More sharing options...
xyph Posted June 5, 2011 Share Posted June 5, 2011 By sticky you mean? I understand focus as when the page loads, the active object is that with focus. Like loading up google.com - focus is given to the query input so you can just start typing, rather than clicking on the input box and then typing. Quote Link to comment https://forums.phpfreaks.com/topic/238485-bring-back-the-focus-item-to-form/#findComment-1225675 Share on other sites More sharing options...
Pikachu2000 Posted June 6, 2011 Share Posted June 6, 2011 Sticky, as in the value that was selected when the form was submitted is selected when it reloads . . . But I suppose we'll have to wait for the OP to clarify what is actually desired. Quote Link to comment https://forums.phpfreaks.com/topic/238485-bring-back-the-focus-item-to-form/#findComment-1225690 Share on other sites More sharing options...
patsman77 Posted June 7, 2011 Author Share Posted June 7, 2011 Thanks to all for your replies - I actually found the issue - it was in another part of the code referencing the "checkpick" function. Quote Link to comment https://forums.phpfreaks.com/topic/238485-bring-back-the-focus-item-to-form/#findComment-1226592 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.