Jump to content

Getting & Setting a HTML Select Value into varable; On The Same Page


Jezza22

Recommended Posts

I would like to open a new window and from the parent window pass the values from a HTML select tag.

 

The problem is when the new/child window opens the variables that are being passed using $_POST are always a one value behind?

 

I think it is because the values for the HTML select tags are set when I submit the page and therefore I need to have some kind of function that gets the values and sets them into a variable in the page before I submit?

 

Please help here's the code: -

 

<html>

<div id="boxed">

<form name='search' method='post' action='search.php<?php echo "?menu=" . $_GET['menu'];?>' onsubmit="window.open('http://localhost/pyramid/fpdf/print.php?<?php echo $_POST['Account_From'] ."&".  $_POST['Account_To'];?>')">

 

<fieldset id='Print_Options'>

<legend>Print Options</legend>

<table>

<tr><td>Account From:</td><td><?php if ($result = mysql_query("SELECT idAccounts_File, Company_Name FROM accounts_file;")) {

if (mysql_num_rows($result)) {

echo "<select name='Account_From'>";

while ($row=mysql_fetch_array($result)) {

if ($row['idAccounts_File'] == $_SESSION['idAccounts_File']) {

echo "<option value='{$row['idAccounts_File']}' selected='selected'>{$row['Company_Name']}</option>";}

else {

echo "<option value='{$row['idAccounts_File']}'>{$row['Company_Name']}</option>";}

}

}

}

echo "</select>";

?>

          <tr><td>Account To:</td><td><?php if ($result = mysql_query("SELECT idAccounts_File, Company_Name FROM accounts_file;")) {

if (mysql_num_rows($result)) {

echo "<select name='Account_To'>";

while ($row=mysql_fetch_array($result)) {

if ($row['idAccounts_File'] == $_SESSION['idAccounts_File']) {

echo "<option value='{$row['idAccounts_File']}' selected='selected'>{$row['Company_Name']}</option>";}

else {

echo "<option value='{$row['idAccounts_File']}'>{$row['Company_Name']}</option>";}

}

}

}

echo "</select>";

?>

<input type="submit" name="Print" Value="Print" class="Ok" title="Print Report"/>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.