Page 1 of 1

Still new to this, this one could be simple

Posted: Sun Oct 13, 2002 10:41 am
by l_jimb_l
If I have a page with something like:
<input type="text" name="f_name" value="First">

How do I pull the name out with PHP? Is there a way to do it like it's done in javascript?
<javascript>
firstName=form.f_name.value;
</javascript>

I know you can set up the value $f_name, but I will tell you why I have the prob.....

for ($i=0; $i < $matches; $i++)
{
$row = mysql_fetch_array($search_row);
echo "<tr>\n<input type=\"hidden\" name=\"id\" value=\"".$row["id"]."\">\n";
echo "<td align=\"center\">".($i+1)."</td>\n<td><span class=\"in\">";
echo $row["u_name"];
echo "</span></td>\n<td><span class=\"in\">";
echo $row["f_name"];
echo "</span></td>\n<td><span class=\"in\">";
echo $row["l_name"];
echo "</span></td>\n<td><span class=\"in\">";
echo $row["dept"];
echo "</span></td>\n";
echo "<td align=\"center\">\n";
echo "<input type=\"submit\" value=\"Del\" name=\"del\">".$row["id"]."";
//echo "<input type=\"button\" value=\"Mod\"></td></tr>\n"; //modify button. Will get to work after Del works
}
echo "</table>\n";

If you look above you will see that the it is a dynamically created table based on $matches. Here, echo "<tr>\n<input type=\"hidden\" name=\"id\" value=\"".$row["id"]."\">\n"; I want to get the value from
value=\"".$row["id"]."\" because I am looking to be able to delete that username if it is no longer needed.

Maybe someone could walk me through this? I am still really new but I am determined to make this thing work.....

Posted: Sun Oct 13, 2002 11:42 am
by volka
maybe this example helps you

Code: Select all

&lt;html&gt;&lt;body&gt;
&lt;fieldset&gt;&lt;legend&gt;example output of transmitted request-data&lt;/legend&gt;
&lt;?php 
	echo '&lt;pre&gt;'; print_r($_POST); echo '&lt;/pre&gt;';
	
	if (isset($_POST&#1111;'i1']))
		echo 'i1-value is: ', $_POST&#1111;'i1'] , '&lt;br&gt;';
	
	if (isset($_POST&#1111;'i2']))
		echo 'i2-value is: ', $_POST&#1111;'i2'] , '&lt;br&gt;';
		
	if (isset($_POST&#1111;'dropdown']))
		echo 'radiobutton-value: ', $_POST&#1111;'dropdown'], '&lt;br/&gt;';

	echo 'dropdown-value: ', isset($_POST&#1111;'radiobutton']) ? $_POST&#1111;'radiobutton'] : '--undefined--', '&lt;br/&gt;';
		
	if (isset($_POST&#1111;'checkarr']))
	{
		echo '&lt;table border="1"&gt;&lt;tr&gt;&lt;th&gt;values in the array &lt;i&gt;checkarr&lt;/i&gt;&lt;/th&gt;&lt;/tr&gt;';
		
		foreach($_POST&#1111;'checkarr'] as $value)
			echo '&lt;tr&gt;&lt;td&gt;', $value, '&lt;/td&gt;&lt;/tr&gt;';
			
		echo '&lt;/table&gt;';
	}
?&gt;
&lt;/fieldset&gt;

&lt;form method="POST"&gt;
	&lt;input type="hidden" name="invisible" value="but still there" /&gt;
	&lt;hr/&gt; text inputs &lt;br/&gt;
	i1: &lt;input type="text" name="i1" value="default" /&gt; &lt;br/&gt;
	i2: &lt;input type="text" name="i2" value="default, too" /&gt; &lt;br/&gt;
	&lt;hr/&gt; selection field &lt;br/&gt;
	&lt;select name="dropdown"&gt;
		&lt;option value="first"&gt;1&lt;/option&gt;
		&lt;option value="second"&gt;2&lt;/option&gt;
		&lt;option value="third" selected="true"&gt;3&lt;/option&gt;
		&lt;option value="fourth"&gt;4&lt;/option&gt;
	&lt;/select&gt;
	&lt;hr/&gt; radio buttons &lt;br/&gt;
	A: &lt;input type="radio" name="radiobutton" value="a"/&gt; &lt;br/&gt;
	B: &lt;input type="radio" name="radiobutton" value="b" checked="true"/&gt; &lt;br/&gt;
	C: &lt;input type="radio" name="radiobutton" value="c"/&gt; &lt;br/&gt;
	D: &lt;input type="radio" name="radiobutton" value="d"/&gt;
	&lt;hr/&gt; checkboxes &lt;br/&gt;
	A: &lt;input type="checkbox" name="checkarr&#1111;]" value="a" checked="true"/&gt; &lt;br/&gt;
	B: &lt;input type="checkbox" name="checkarr&#1111;]" value="b" checked="true"/&gt; &lt;br/&gt;
	C: &lt;input type="checkbox" name="checkarr&#1111;]" value="c"/&gt; &lt;br/&gt;
	D: &lt;input type="checkbox" name="checkarr&#1111;]" value="d"/&gt; &lt;br/&gt;
	&lt;input type="submit" /&gt;	
&lt;/form&gt;
&lt;/body&gt;&lt;/html&gt;

thanks

Posted: Tue Oct 15, 2002 8:59 am
by l_jimb_l
Wow, that's great. That's exactly what I needed to see. It pushed me totally in the right direction. Thanks a ton.