Click to See Complete Forum and Search --> : onclick = submit the form


Nibinaear
March 4th, 2005, 12:32 PM
I have part of a script here which basically produces links, which when clicked, pass a value to a javascript function. The function then sets a hidden form element to the value and the form is submitted. The only thing is that the form never gets submitted.


<script language= "javascript">
function passValue(i)
{
document.edit.hide.value = i;
window.edit.submit();

//var test = document.edit.hide.value;
//document.write("We are definitely in the function");
}
</script>

<?

$query = odbc_exec($odbc,$input);

$i=0;

while($record = odbc_fetch_array($query))
{
$id[$i] = $record['assessment_id'];
$Mod[$i] = $record['Module'];
$Type[$i] = $record['type'];
$Desc[$i] = $record['Description']."<p/>";
$i++;
}

//counts the rows in the query
$rows = odbc_num_rows($query);

//while the index is less than number of rows.
while($i<$rows)
{
echo "<a href='' onClick = 'passValue(\"".$id[$i]."\");'>".$Mod[$i].", ".$Type[$i].", ".$Desc[$i]."</a><p/>";
$i++;
}
?>

<input type = 'hidden' name = 'hide'>
</form>
</td></tr></table>

<p/>

<?
readfile('imp/bottom.html');
?>


A lot of the code has been removed to simplify it, I know the other code does for the connection to the db etc.

I have got a form to submit by this method before, i.e. window.edit.submit(); the only difference being that this time I don't have an <input type = "submit">. Any ideas?

Nibinaear
March 4th, 2005, 01:55 PM
Wow, all that code and all I did was forgot to put a # in the

<a href = "#"