PDA

View Full Version : passing variable into popup


perayo
05-12-2003, 11:16 PM
I would search for this, but I keep getting 'timeout 60 seconds'.

I have a poll (let's say #2) on index.php3 and display in a pop-up (poll.php3?id=2). And the code on index.php3 is

echo "<form action='poll.php3?id=".$list["id"]."' method='post' onsubmit=\"javascript:window.open('poll.php3?id=".$list["id"]."','','status=0,menubar=0,toolbars=0,scrollbars=0,location=0,resizable=0,width=300,height=300');\">";
echo "<b>".$list["ask"]."</b><BR>";
echo "<input type='radio' name='opt' value='opt1cnt'>".$list["opt1"]."<BR>";
echo "<input type='radio' name='opt' value='opt2cnt'>".$list["opt2"]."<BR>";
echo "<input type='radio' name='opt' value='opt3cnt'>".$list["opt3"]."<BR>";
echo "<input type='radio' name='opt' value='opt4cnt'>".$list["opt4"]."<BR>";
echo "<input type='radio' name='opt' value='opt5cnt'>".$list["opt5"]."<BR>";
echo "<input type='submit' value='submit'>";
echo "</form>";

Problem is that, index.php3 reloads and displays the results as well as poll.php3?id=2 popping up and *not* displaying the updated results. Adding 'return false' did not work cuz the db is not updated and so poll.php3?id=2 just popped up without displaying the updated results.

I want it so that index.php3 does not reload, and poll.php3?id=2 popping up (without toolbar,scrollbar,etc.) displaying the updated results. Any solutions?
thanks.

raf
05-13-2003, 08:08 AM
Welcome here.
Now, i don't immediately see the MySQL link and i'm not clear on your problem. According to this code, you load index.php3 (Why still php3?) and you display the question and the alternatives. ok. now you submit this page to poll.php3. The updating statement should be inside poll.php3. After the update, you should check if a record was updated and then select that updated record. Compose the message and send it to the browser. So we need to see the code of poll.php3.

Also, you don't want index.php3 to reload. So what should then happen?

Maybe an alternative to updating the database and then displaying the updated results, is jusing javascrip and do it all clientsided. When you load the page, you store the results (total number of votes, number for each alternative etc inside some array and you update these values to compute the changed result. All clientsided. The you open the popup and display the computed results. If the client closes the popup, you update the db.

Why use a popup? Not everyone likes them and you can just as well display the results inside the page. (post the page to itself and check the length of 'opt' on top of the page)