CincoPistolero Posted June 4, 2009 Share Posted June 4, 2009 I have a php page that has two buttons at bottom of page. Each takes viewer to new page based on <input type="submit" name="a" ... yada yada. this works fine. however I'm trying to attach an ID to the redirects. As I'll show below, I've created a plain jane page that only serves the purpose of proving this is possible and it works. I take the same code and place it in a more robust php page and it does not work, it sends me to the next page, but does not attach the ID value. Below is my code. for trouble shooting I've even echo the ID value lower on the page to prove it is present. any help is greatly appreciated. Code from page that works <?php $awoID=5; if (isset($_POST['tt'])) { // if form has been submitted ?> <script language='javascript'> location.replace('send.php?awoID="<?php echo $awoID; ?>"'); </script> <?php } else if(isset($_POST['tv'])) { ?> <script language='javascript'> location.replace('edit.php?awoID="<?php echo $awoID; ?>"'); </script> <?php } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" name="form" method="post"> <input type="submit" name="tt" value="edit"> <input type="submit" name="tv" value="send"> </form> <?php } ?> some of the code from page that does not work. <?php $queryusers = "SELECT userID, lastName, firstName FROM users WHERE userName='$salesTitan';"; $resultusers = mysql_query($queryusers) or die ("Error in query: $queryusers. " . mysql_error()); $usersrow= mysql_fetch_array($resultusers); extract($usersrow); $f_name=$usersrow['firstName']; $l_name=$usersrow['lastName']; $uID=$usersrow['userID']; ?> <?php //New Submissions Query $query = " SELECT * FROM artWO WHERE awoID='$awoID'"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); $row= mysql_fetch_array($result); extract($row); $preDot = substr($row['phoneNum'],0,3); $postDot = substr($row['phoneNum'],3,4); $awoID = $row['awoID']; ?> <?php if (isset($_POST['mo'])) { // if form has been submitted ?> <script language='javascript'> // location.replace('makeOrder.php?awoID="<?php echo $row['awoID']; ?>"'); location.replace('send.php?awoID="<?php echo $awoID; ?>"'); </script> <?php } else if(isset($_POST['edit'])) { ?> <script language='javascript'> location.replace('editWO.php?awoID="<?php echo $row['awoID']; ?>"'); </script> <?php } else { ?> <div id="main"> Link to comment https://forums.phpfreaks.com/topic/160945-solved-passing-php-variable-to-a-javascript-locationreplace/ Share on other sites More sharing options...
CincoPistolero Posted June 4, 2009 Author Share Posted June 4, 2009 I finally figured it out. I had send.php?awoID="<?php echo $awoID; ?>" this of course sends "some #" as the ID. and I need just some # without the quotes. I removed the quotes from around the php echo statement, and now I am golden. Link to comment https://forums.phpfreaks.com/topic/160945-solved-passing-php-variable-to-a-javascript-locationreplace/#findComment-849399 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.