Option Values

below i have some code that will post the txtid to my script that will query what i need to cause it’s not posting it with an id my sent.php script keeps failing.

how would i set the dropdown an id of say messageid


<form action="./include/sent.php" method="post" id="smsstatus">
<select id="messageid">
  <option value="<?php echo (''.$row['txtid'].'') ;?>"><?php echo (''.$row['to'].'') ;?></option>
</select>
<input name="status" data-role="button" data-inline="true" type="submit" value="submit" />
</form>
 <div id="result"></div>
</body>
</html>

Can we see the sent.php code too?


<?php
//initilize PHP
if ( isset ( $_POST['status'] ) ) //If submit is hit
{
// Message Details
	$message_id= $_POST['messageid'];
echo (''.$messageid.'');
?>

sent.php does more but this is the essential bit

Do a print_r($_POST); in sent.php, and see what exactly is being sent

when i run firebug it shows that the txtid is being set but no parameter set

Okay, your issue is 1 of 2 likely places. 1) $row[‘txtid’] is blank, thus the value of your drop down option is blank. 2) the data isn’t getting to sent.php or being read properly in sent.php.

So start with your dropdown. View the Source of the page and make sure the drop down actually has a value (that isn’t spaces/blank).
Then submit the form after adding var_dump($_POST); to your sent.php so you can see what data is being received by sent.php.

From what you’ve done so far and what you have provided us, my guess is $row[‘txtid’] doesn’t contain what you think it does.

when checking the html the value field is populated.
this is what i see via firebug

where the long number is that is the value i wish to capture.

i get the following if i print the $post

array(1) { [“status”]=> string(6) “submit” }

Bingo!

<select id="messageid"> 
  <option value="<?php echo (''.$row['txtid'].'') ;?>"><?php echo (''.$row['to'].'') ;?></option> 
</select> 

See the issue? That’s okay, we all missed it multiple times. You defined an ID, but you never gave it a NAME!

<select id="messageid" name="messageid"> 
  <option value="<?php echo (''.$row['txtid'].'') ;?>"><?php echo (''.$row['to'].'') ;?></option> 
</select> 

That should solve your issue.

cpradio - my friend you are spot on with that fix!

thank you very very much!