[ create a new paste ] login | about

Link: http://codepad.org/1O0PpQ7R    [ raw code | output | fork ]

PHP, pasted on Feb 10:
 <?php      
	$uv = FALSE;	
	


        
	function buildVotes($selectedIndex, $uv){
		$noOfVotes = 10;
		$selectMenu = '<td align="left"><select class="articlevote" name="article_vote">';
		$options = "";
		for($i = 0; $i<$noOfVotes; $i++){
			if($uv == true){
				$selected = ($selectedIndex == $i) ? 'selected="selected"'  : "";
			}
			if($i == 0){
				if($uv == false){
					$selected = 'selected="selected"';
				}
				$options .= '<option id="vote'.$i.'" value="'.$i.'" '.$selected.' >No Vote</option>';
			}else{
				$options .= '<option id="vote'.$i.'" value="'.$i.'" '.$selected.' >'.$i.'</option>';
			}
		}
		$selectMenu .= $options."</select></td>";
		echo $selectMenu;
	}

buildVotes(5, false)
?>


Output:
1
 <td align="left"><select class="articlevote" name="article_vote"><option id="vote0" value="0" selected="selected" >No Vote</option><option id="vote1" value="1" selected="selected" >1</option><option id="vote2" value="2" selected="selected" >2</option><option id="vote3" value="3" selected="selected" >3</option><option id="vote4" value="4" selected="selected" >4</option><option id="vote5" value="5" selected="selected" >5</option><option id="vote6" value="6" selected="selected" >6</option><option id="vote7" value="7" selected="selected" >7</option><option id="vote8" value="8" selected="selected" >8</option><option id="vote9" value="9" selected="selected" >9</option></select></td>


Create a new paste based on this one


Comments: