Jump to content

post issue


Jay2391

Recommended Posts

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">";

}


Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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">";

}
?>

Link to comment
Share on other sites

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>";
?>


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.