0

Following on from a previous question, (previous question here), the problem I'm having seems to involve trying to pass/post a value through a form when the form action is '#'. I've tried session data but it always returns the last item from the database. Everthing else returns nothing.

Any help/ideas/advice greatly received, S. (Code below)

This is the code that displays the list of items, each containing an 'email' link/button to one instance of a popup window/form that is located at the bottom of the page.

<?php                   
$query = mysql_query("select * from istable where categoryID = '1'");       
while ($result = mysql_fetch_array($query)) {               
echo '<h4>'.$result['title'].'</h4>
<p>'.substr($result['descrip'],0,408).'... <a href="'.$wwwUrl.'/p/'.$result['categoryID'].'-'.$result['title'].'.php""><strong>Read more</strong></a></p>

<form action="#" method="post" rel="#sheet" class="see">                                    
<input type="hidden" name="propTitle" value="'.$propResult['title'].'">
<input type="submit" name="submit" value="Email">
</form> 
    ';        
} 

?>

This is the code for the popup window/form at the bottom of the same page that is called through jquery.

<div id="sheet" class="rounded">
  <!--{{{ pane1 -->
      <div class="pane" id="pane1">
      <h4>Email Details to a Friend</h4>            
      <p>You have selected to forward the details of <?php echo $_POST['propTitle']; ?> to a friend.</p>
      <p>Please fill out the following form</p>
          <form class="rounded" id="email-form" method="post" action="<?php echo $pageLink; ?>"> 
          <!-- form goes in here -->                 
          </form>   
      </div>
      <!--}}}-->                
  </div>

    <script type="text/javascript">         
    $(".see").overlay({mask: '#999', fixed: false}).bind("onBeforeClose", function(e) {
    $(".error").hide();
    });         
    </script>   
1
  • Why are you using '#' in the action? You can remove it if you will submit it to the same page. Or use '?' instead. Commented Feb 2, 2011 at 12:08

1 Answer 1

1

Why are you using PHP for this? If the popup is called through the same page, use JavaScript to get the DOM element value and if you need to process data use AJAX.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks but how do you do that? what would I need to search for?
You need to call get rid of the submit and use a button. With the button, add an onclick attribute that calls a defined JavaScript function. Within that function, process your data with a jQuery AJAX call and then open the popup. Get the values with a jQuery select. You have to add an ID attribute to your field. jQuery selector: $('name').val().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.