dave007 Posted June 24, 2009 Share Posted June 24, 2009 I have xml files for a whole bunch of data. I have managed to get them into a nice format and showing on an html page fine. I can even go backwards and forwards between xml files. To do this I simply use a $_GET['rec'] variable. However, I've been trying to ALSO have things update on the page when the user selects (preferably just clicks on) an item in a <select> tag - populated from the XML file. Below is my latest attempt at this (with the population of the <select>): echo "<form id=v2p method=\"POST\"><select size = 5 onclick=\"javascript:document.v2p.submit();return false;\">"; $vars = $xmlDoc->getElementsByTagName('var'); foreach($vars as $var) { $varname = $var->getElementsByTagName('vaname')->item(0)->nodeValue; echo "<option value=$varname>$varname</option>"; } echo "</select></form>"; echo "<br/>"; $var2plot = $_POST['v2p']; echo "<a>$var2plot</a>"; I get an "Undefined index: v2p" error on line 75 ($var2plot = $_POST['v2p']; ): Please could someone show me a nice way to make it work... Thanks in advance, Dave Quote Link to comment https://forums.phpfreaks.com/topic/163471-using-a-form-to-update-the-same-page-all-in-php-and-other-veriables/ Share on other sites More sharing options...
JonnoTheDev Posted June 24, 2009 Share Posted June 24, 2009 The POST array uses field NAMES for its indexes you haven't defined any i.e. // $_POST['v2p'] will contain the value of the following field after form submission i.e. 123 <input type="text" name="v2p" id="xyz" value="123" /> Quote Link to comment https://forums.phpfreaks.com/topic/163471-using-a-form-to-update-the-same-page-all-in-php-and-other-veriables/#findComment-862748 Share on other sites More sharing options...
dave007 Posted June 25, 2009 Author Share Posted June 25, 2009 I think this is a problem with sending two GET requests... I've managed to make the form update one of the <form name="VarForm" action="' . $_SERVER['PHP_SELF'] . '" method="GET"><select name = "v2p" size=5 OnChange="VarForm.submit();">'; but now the 'rec' variable is lost... please could someone save my hair from all being pulled out. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/163471-using-a-form-to-update-the-same-page-all-in-php-and-other-veriables/#findComment-863148 Share on other sites More sharing options...
dave007 Posted July 1, 2009 Author Share Posted July 1, 2009 Is there any way to keep the other vraiable? Quote Link to comment https://forums.phpfreaks.com/topic/163471-using-a-form-to-update-the-same-page-all-in-php-and-other-veriables/#findComment-866854 Share on other sites More sharing options...
JonnoTheDev Posted July 1, 2009 Share Posted July 1, 2009 Is there any way to keep the other vraiable? Keep persistent with any of the following: 1. A session variable 2. A hidden field for post / get 3. A url parameter Quote Link to comment https://forums.phpfreaks.com/topic/163471-using-a-form-to-update-the-same-page-all-in-php-and-other-veriables/#findComment-866983 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.