When I'm passing a form id to JavaScript function, the actual value what is passed there is not a string but [object HTMLFormElement]
.
Here is the code of a JavaScript:
function hideSowDiv(id) {
alert(id);
if (document.getElementById(id).style.display == "none") {
document.getElementById(id).style.display = "block";
} else {
document.getElementById(id).style.display = "none";
}
}
and it is a php part of the code:
while($ProductList = mysql_fetch_array($GetUers)){
echo "<div >";
echo "<input type='submit' name='OpenBtn' value='+' onclick='hideSowDiv(ItemUnit".$ProductList[0].")' > ";
echo "<span >".$UserList[4]." </span>";
echo "</div>";
//echo "<div id='".$UserList[0]."' style='display:none;>";
populateUserDivs($ProductList[0]);
//echo "</div>";
}
function populateUserDivs($Id){
$List_Query = "SELECT * FROM product WHERE product_id = ".$Id.";";
$GetList = mysql_query( $List_Query, $Connection ) or die("ERROR".mysql_error());
while($Output_List = mysql_fetch_array($GetList))
echo "<form id='ItemUnit".$UserId."' name='ItemUnit".$UserId."' method='POST' style='display:none;' >";
echo "<span class='AddingForm' > Name*: </span> <input type='textbox' name='UserName' class='Text_boxes' value='".$Output_List[1]."' required> ";;
echo "<input type='submit' name='EdtItem".$Output_List[0]."' id='DelItem".$Output_List[0]."' value='save' '>
echo " </form>";
}
}
So I wonder what am I doing wrong that the form id is not being passed to the JavaScript function, but the [object HTMLFormElement]
instead.
The reason I'm passing the form id is if I put the form inside a div, the submit button is being treated just like an image and form is not working at all.
So if somebody can point me how can I turn the [object HTMLFormElement]
into the form id I will be really grateful.