Jump to content

function how to autogenerate a name for form element?


zgkhoo

Recommended Posts

function displaybetbutton($mode){
    echo "
	<input type=submit name=[color=red]$mode+"even"[/color] value=97%>
	</td>
	<td>
	<input type=submit name=[color=red]$mode+"odd"[/color] value=97%>
	</td>
	<td>
	<input type=submit name=[color=red]$mode+"big"[/color] value=97%>
	</td>
	<td>
	<input type=submit name=[color=red]$mode+"small"[/color] value=97%>
	</td>		
	</tr>
	<tr>";

}

 

wat is wan is php generate the $mode+"stringThatIwanCombine"

anyone know how? thanks..

 

function displaybetbutton($mode){

    echo "

<input type=submit name=$mode+"even" value=97%>

</td>

<td>

<input type=submit name=$mode+"odd" value=97%>

</td>

<td>

<input type=submit name=$mode+"big" value=97%>

</td>

<td>

<input type=submit name=$mode+"small" value=97%>

</td>

</tr>

<tr>";

 

}

 

wat is wan is php generate the $mode+"stringThatIwanCombine"

anyone know how? thanks..

 

This is one way to write the script:

<?php
function displaybetbutton($mode){
      $modes = array('even','odd','big','small');
      foreach ($modes as $m) {
    echo "<td>
                <input type='submit' name='" . $mode . $m ."' value='97%'>
	</td>";
      }
       echo "</tr>
	<tr>";
}?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

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