Jump to content

Basic onclick html form


Drissical

Recommended Posts

I have a site that has you search for items in a database and then shows you a list, the list is generated in a table and on each row is 1 item and 1 button. The entire table is put in a form tag and then there is a hidden input right above the table. Each row is generated based on how many things you find.

 

Right now this is how it is all setup on there. Dont mind my mess o.0. also the page is PHP.

This gets hit after hitting submit on the search.

if (isset($_POST['search_sub'])){
if ($_POST['search_sub'] == "Search"){
echo "<form method=post><input id=\"hiddenresultselect\" type=hidden value=\"\" name=result_to_add>";
echo "<table width=100%>";
while($sr=mysql_fetch_array($sqls)){
echo "<tr>
		<td>{$sr['title']}</td>
		<td width=30>
				<input OnClick=\"insertresult({$sr['id']})\" type=submit name=result_add value=\" + \">
		</td>
	</tr>";

}
echo "</table>";
echo "</form>";
}
}

 

the java function

function insertresult(resultid){
hiddenresultselect.value = resultid
}

and this is the PHP that puts what you picked in to a session

if (isset($_POST['result_add'])){
array_push($_SESSION['sescon'],$_POST['result_to_add']);
} 

 

 

The problem im having is that in firefox when i hit that " + " button it sends the id in to the session and i can see it in the middle in IE it does not and on the lower left corner i can see a warning flash. Firefox is changing the value of the hidden item and IE is like ?? when you hit the submit.

For what its worth using Apache 2 mySQL 5.0.45 and PHP 5.2.4.

 

I want to know what is it that im doing that IE does not like, there may be something i need to adjust all together to make it play nice but im not seeing anything. My Java is about a week old btw.

 

Link to comment
Share on other sites

not quit sure what you are trying to do, but this may help - try it and see if it works the way you want it to:

 

<?php

if (isset($_POST['result_add'])){
array_push($_SESSION['sescon'],$_POST['result_to_add']);
} 

?>

<script lanaguage="javascript">
function insertresult(resultid){
document.myForm.result_to_add.value = resultid
}
</script>

</head><body>

<?php

if (isset($_POST['search_sub'])){
if ($_POST['search_sub'] == "Search"){
echo "<form name="myForm" method=post><input id=\"hiddenresultselect\" type=hidden value=\"\" name=result_to_add>";
echo "<table width=100%>";
while($sr=mysql_fetch_array($sqls)){
echo "<tr>
		<td>{$sr['title']}</td>
		<td width=30>
				<input OnClick=\"insertresult({$sr['id']})\" type=submit name=result_add value=\" + \">
		</td>
	</tr>";

}
echo "</table>";
echo "</form>";
}
}


?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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