Jump to content

Dam this form


Obi1-Cannabis

Recommended Posts

i'm working with javascript and php to make a form that for each product of a DB has a diferent valuehow can i do this without having to use a submit button? because the onclick="document.form.submit();", where 'form' is a php variable doesn't work however the name of the form can be a php variable.please help

Link to comment
Share on other sites

That would work fine if my DB had only one element, but that's not the case...

foreach($tipop as $k2=>$v2 ){if ($tipop[$k2]['IDFamilia'] == $familia[$k]['ID']){	$this->idt=$tipop[$k2]['ID'];	print"  <tr> 		<form method='Post' action='index.php' name='".$k2."' id='".$k2."'>			<input type='hidden' name='comando' value='escolhi'>			<input type='hidden' name='idt' value='".$tipop[$k2]['ID']."'>		</form>			<td width='200' align='left' onclick=\"document.".$k2.".submit();\"style=\" cursor:pointer; cursor:hand;\" onmouseover=\"bgColor='lightyellow';\" onmouseout=\"bgColor='white';\">		".$tipop[$k2]['Descricao']."							</td>						   </tr>";	}}

This is what's not working...

Link to comment
Share on other sites

That would work fine if my DB had only one element, but that's not the case...
foreach($tipop as $k2=>$v2 ){if ($tipop[$k2]['IDFamilia'] == $familia[$k]['ID']){	$this->idt=$tipop[$k2]['ID'];	print"  <tr> 		<form method='Post' action='index.php' name='".$k2."' id='".$k2."'>			<input type='hidden' name='comando' value='escolhi'>			<input type='hidden' name='idt' value='".$tipop[$k2]['ID']."'>		</form>			<td width='200' align='left' onclick=\"document.".$k2.".submit();\"style=\" cursor:pointer; cursor:hand;\" onmouseover=\"bgColor='lightyellow';\" onmouseout=\"bgColor='white';\">		".$tipop[$k2]['Descricao']."							</td>						   </tr>";	}}

This is what's not working...

Obi1,The code you have will work as long as the value in $k2 will create a valid form name. If $k2 contains spaces, special characters, etc., it will fail.
Link to comment
Share on other sites

Obi1,The code you have will work as long as the value in $k2 will create a valid form name. If $k2 contains spaces, special characters, etc., it will fail.
Yes i found the problem already, the thing is that i was trying to use integer for the name. but thanks anyway.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...