Jay2391 Posted November 2, 2007 Share Posted November 2, 2007 Okay here is my issue , I am weak at the posting and HTML deal... So i have a simple drop down and I want that when i select from the drop down and click submit that my browser will change to website.php?get_something=$i&another=$b the issue is that the first time i click submit it sytays the same ...the second time it changes to the prior selection... I do not want to click twice to get my result any Ideas...here is the code i clean it up a lot but that is the main idea $i= $_GET['i']; $b = $_GET['b']; echo "$i and $b"; print "<form action=md_challenge.php?i=$i&a=TRUE method='post'>"; <select class="newsmall" name="i"> <option value="1">opt1</option></p> <option value="2">opt2</option></p> <option value="3">3</option></p> </select <input type="submit" name="submit" size"20" value="submit">"; } Quote Link to comment https://forums.phpfreaks.com/topic/75823-post-issue/ Share on other sites More sharing options...
otuatail Posted November 2, 2007 Share Posted November 2, 2007 Not sure what you mean by change to website.php. Are you trying to load a diffrent page depending on the value of the drop down box. What php pages are used? Quote Link to comment https://forums.phpfreaks.com/topic/75823-post-issue/#findComment-383767 Share on other sites More sharing options...
Jay2391 Posted November 2, 2007 Author Share Posted November 2, 2007 is a ticky form so i use the same page ....md_challenge.php in this case the issue is that the first time click submit .. the browser shows... $i =100; md_challenge.php?i=&a= the secint time i click submit i get md_challenge.php?i=100&a=TRUE Quote Link to comment https://forums.phpfreaks.com/topic/75823-post-issue/#findComment-383771 Share on other sites More sharing options...
otuatail Posted November 2, 2007 Share Posted November 2, 2007 Ok then this is probably what you need to do If you are posting back to the same page with the drop down list. The first thing you need to do is get the selected value of the drop down. $Value = $_POST['i']; // Then make that the current selection <select class="newsmall" name="i"> <option value="1"<? if($value == 1) {?> SELECTED <?}?>>opt1</option> <option value="2"<? if($value == 2) {?> SELECTED <?}?>>opt2</option> </select> Desmond Quote Link to comment https://forums.phpfreaks.com/topic/75823-post-issue/#findComment-383773 Share on other sites More sharing options...
Jay2391 Posted November 2, 2007 Author Share Posted November 2, 2007 that won't work i still have to click submit twice to get the result my issu is not the diplay is why the first time i click submit I do not get the result post on the browser??? Quote Link to comment https://forums.phpfreaks.com/topic/75823-post-issue/#findComment-383779 Share on other sites More sharing options...
Jay2391 Posted November 2, 2007 Author Share Posted November 2, 2007 all my code is inside php FYI Quote Link to comment https://forums.phpfreaks.com/topic/75823-post-issue/#findComment-383783 Share on other sites More sharing options...
otuatail Posted November 2, 2007 Share Posted November 2, 2007 in your code you didn't have SELECTED in the code so it could not have changed. What do you mean by I do not get the result post on the browser? Is ther some code missing? why does your submit button have size"20" this dosn't do anything. Maybee more of the code? as this should work. place an echo $Value; after the $Value = $_POST['i']; This should have the value. Quote Link to comment https://forums.phpfreaks.com/topic/75823-post-issue/#findComment-383784 Share on other sites More sharing options...
Jay2391 Posted November 2, 2007 Author Share Posted November 2, 2007 Hope this clarifies you question on what I am looking for.... /////the code is inside md_challenge.php <?php $i =100; ////the browser shows... /////md_challenge.php?i=&a= /////the second time I click submit i get /////md_challenge.php?i=100&a=TRUE $i= $_GET['i']; $b = $_GET['b']; echo "$i and $b"; print "<form action=md_challenge.php?i=$i&a=TRUE method='post'>"; <select class="newsmall" name="i"> <option value="1">opt1</option></p> <option value="2">opt2</option></p> <option value="3">3</option></p> </select <input type="submit" name="submit" size"20" value="submit">"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/75823-post-issue/#findComment-383788 Share on other sites More sharing options...
phpSensei Posted November 2, 2007 Share Posted November 2, 2007 i did not understand you. <?php // Sorry dude, i dont understand what you mean... but $i = 1; // change this to whatever $b = 2; // also change print "<form action ='".$_SERVER['PHP_SELF']."?i=".$i."&&b=".$b."' method = 'post' > <select class="newsmall" name="i"> <option value=\"1\">opt1</option></p> <option value=\"2\">opt2</option></p> <option value=\"3\">3</option></p> </select> <input type=\"submit\" name=\"submit\" size\"20\" value=\"submit\"> </form>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/75823-post-issue/#findComment-383796 Share on other sites More sharing options...
otuatail Posted November 2, 2007 Share Posted November 2, 2007 Sorry I miised one of your lines in a reply the browser shows... $i =100; $i= $_GET['i']; $b = $_GET['b']; WRONG $i= $_POST['i']; $b = $_POST['b']; Quote Link to comment https://forums.phpfreaks.com/topic/75823-post-issue/#findComment-383797 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.