AggieIE
AggieIE

Reputation: 125

Incremented Select ID Name

Im trying to loop through some dynamically created select ID's in my php file and I keep running into issues in getting it to work. The error message I keep on receiving is "Notice: Undefined index: selectcell0"

PHP

for($i=0; $i<$_SESSION["arr"]; $i++){
	if($_POST['selectcell'.$i]=='Closed')
	{
		echo "Working";
	}
}

HTML

<td width="10%" align="left" class="no-padding">
  <select id="selectcell<?php echo $i;?>" style="WIDTH: 100px; HEIGHT: 20px" type="text" cellpadding="0" cellspacing="0">
    <option value="Closed" style="background-color:#66FF66" id="closedcheck">Closed</option>
    <option value="In Progress" style="background-color:#FF0000" id="inprog" selected="selected">In Progress</option>
  </select>
</td>

PHP

Upvotes: 0

Views: 34

Answers (1)

CT14.IT
CT14.IT

Reputation: 1747

You need to set the name of the select object.

<select name="selectcell<?php echo $i;?>">

Posting items uses the element name NOT the element ID

Upvotes: 1

Related Questions