J
Joop
Hi all,
I'm kinda new to JavaScript, but hey... I'm trying anyway! ;-)
So, here's my problem :
I've created a table in my document, presenting a list of items, one
can 'select' by clicking on it... (Kinda like a menu, you make your
choice from) But since this table can get very long, I've put
something of a 'search-form' on top, which enables the user to make a
selection of products from the list.
Now, the form uses a "post" method, and submits to itself, using the
form action. Some PHP script will make sure that the form is filled
out already, the next time it's presented.
The table, containing a list of products is presented, below the form.
When a user clicks on a product, the product should be "selected". At
first i just used a <a href="zoeken.php?prod_id=24"> link to do this,
but the problem is that my form won't remain in tact.
So now, the global idea is to submit the form after setting a hidden
form-field using JavaScript, using a onClick event.
Here's my code :
<-- the script -->
<head>
<script language="JavaScript">
<!--
var old_Color;
function select_this(id)
{
old_Color = document.getElementById(id).style.backgroundColor;
document.getElementById(id).style.backgroundColor = '#FFCCCC';
}
function deselect_this(id)
{
document.getElementById(id).style.backgroundColor = old_Color;
}
function submit_this(id)
{
document.forms['zoeken'].select_id.value = id;
document.forms['zoeken'].submit();
}
-->
</script>
</head>
<body>
<-- the form -->
<form name="zoeken" action="zoeken.php" method="post" style="margin:
5px;">
<-- a very long form with a lot of variable goes here -->
<input type="submit" value="Zoeken" class="formulierknop">
<input type="hidden" name="select_id" value="">
</form>
<-- the tablerows, in the table, all look like this -->
<tr id="1" onClick="submit_this(1);" onMouseOver="select_this(1);"
onMouseOut="deselect_this(1);" style="cursor: hand; background-color :
'transparent';">
</tr>
Cool huh?!? Everything seems to work, but the submit function. Did I
do something terribly wrong?!? I probably did... :-(
WHY WON'T MY FORM SUBMIT WHEN I CLICK ON A TABLE-ROW?!?!?!?!? :-S
Thnx in advance to everyone spending time on this! ;-)
I'm kinda new to JavaScript, but hey... I'm trying anyway! ;-)
So, here's my problem :
I've created a table in my document, presenting a list of items, one
can 'select' by clicking on it... (Kinda like a menu, you make your
choice from) But since this table can get very long, I've put
something of a 'search-form' on top, which enables the user to make a
selection of products from the list.
Now, the form uses a "post" method, and submits to itself, using the
form action. Some PHP script will make sure that the form is filled
out already, the next time it's presented.
The table, containing a list of products is presented, below the form.
When a user clicks on a product, the product should be "selected". At
first i just used a <a href="zoeken.php?prod_id=24"> link to do this,
but the problem is that my form won't remain in tact.
So now, the global idea is to submit the form after setting a hidden
form-field using JavaScript, using a onClick event.
Here's my code :
<-- the script -->
<head>
<script language="JavaScript">
<!--
var old_Color;
function select_this(id)
{
old_Color = document.getElementById(id).style.backgroundColor;
document.getElementById(id).style.backgroundColor = '#FFCCCC';
}
function deselect_this(id)
{
document.getElementById(id).style.backgroundColor = old_Color;
}
function submit_this(id)
{
document.forms['zoeken'].select_id.value = id;
document.forms['zoeken'].submit();
}
-->
</script>
</head>
<body>
<-- the form -->
<form name="zoeken" action="zoeken.php" method="post" style="margin:
5px;">
<-- a very long form with a lot of variable goes here -->
<input type="submit" value="Zoeken" class="formulierknop">
<input type="hidden" name="select_id" value="">
</form>
<-- the tablerows, in the table, all look like this -->
<tr id="1" onClick="submit_this(1);" onMouseOver="select_this(1);"
onMouseOut="deselect_this(1);" style="cursor: hand; background-color :
'transparent';">
</tr>
Cool huh?!? Everything seems to work, but the submit function. Did I
do something terribly wrong?!? I probably did... :-(
WHY WON'T MY FORM SUBMIT WHEN I CLICK ON A TABLE-ROW?!?!?!?!? :-S
Thnx in advance to everyone spending time on this! ;-)