So, I'm working with a page that displays some links to specific people pages. I'm using a hyperlink to submit my forms. I have this code in a loop and am using the integer $position
to give different id
s to the multiple forms on the page.
Why does this work:
<form id="<? echo "Form" . $position;?>" method="post" action="../lecture">
<input type="hidden" name="personID" value="<? echo $indexstr;?>">
</form>
<a href="#" onclick="<? echo "Form" . $position ;?>.submit()" ><? echo $firstname. ' ' . $lastname;?></a>
and this doesn't:
<form id="<? echo $position . "Form";?>" method="post" action="../lecture">
<input type="hidden" name="personID" value="<? echo $indexstr;?>">
</form>
<a href="#" onclick="<? echo $position . "Form" ;?>.submit()" ><? echo $firstname. ' ' . $lastname;?></a>
In case there was a problem with types and $position
being an integer, I even tried converting it to a string before concatenating using strval()
. The only difference is the order in which I concatenate "Form" and $position
.
I really just want to understand. Thank you in advance for any responses I get.