473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

javascript submit problem : form won't submit

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! ;-)
Jul 23 '05 #1
6 4006
Hi Joop,

I put your code in a html file (ie6.0) and it works...?

But what you can try to include your table (with the code rows)
between the <form></from> tags.

Maybe this works?

Hippo from [NL]
--
remove xxx from mail
Jul 23 '05 #2
Sorry, but it also work in a php file.

No offense, but are you using table cells in your table rows?

Like:

<tr id="1" onClick="submit_this(1);" onMouseOver="select_this(1);"
onMouseOut="deselect_this(1);" style="cursor: hand; background-color :
'transparent';">

<td>blablabla</td>

</tr>

otherwise it is very difficult to determine where to click:)

Please response your results

Greetz,
Hippo from [NL]
--
remove xxx from mail
Jul 23 '05 #3
Ok,

thanks for reply-ing this quickly!!!

Perhaps I should have mentioned that my code is placed in an <iframe>
named "content". I don't really know if that makes a difference.

I have a file called "index.php" with the <iframe name="content"
src="zoeken.php"></iframe>, and then I have a file called "zoeken.php"
with the code in it as mentioned above!

And yes, I did put some <td></td> cells in there as well, but they're
"code-less", so I felt no need to bother any reader with that! ;-)

The code does change the variable "select_id", so when I manually submit
the form, using the submit button, after clicking on one of the <tr>'s,
the clicked <tr> is selected. But I want my form to submit in the
onClick event! :-)

Anybody?!?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #4
You could submit your form by javascript:
document.YOURFORMNAME.submit();

Ok,

thanks for reply-ing this quickly!!!

Perhaps I should have mentioned that my code is placed in an <iframe>
named "content". I don't really know if that makes a difference.

I have a file called "index.php" with the <iframe name="content"
src="zoeken.php"></iframe>, and then I have a file called "zoeken.php"
with the code in it as mentioned above!

And yes, I did put some <td></td> cells in there as well, but they're
"code-less", so I felt no need to bother any reader with that! ;-)

The code does change the variable "select_id", so when I manually submit
the form, using the submit button, after clicking on one of the <tr>'s,
the clicked <tr> is selected. But I want my form to submit in the
onClick event! :-)

Anybody?!?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Jul 23 '05 #5
Nope... Won't work either... Sorry... :-(

Anybody?!? I'm stuck at this for over a week now, and don't have the
foggiest idea to what's wrong...
You could submit your form by javascript:
document.YOURFORMNAME.submit();

Ok,

thanks for reply-ing this quickly!!!

Perhaps I should have mentioned that my code is placed in an <iframe>
named "content". I don't really know if that makes a difference.

I have a file called "index.php" with the <iframe name="content"
src="zoeken.php"></iframe>, and then I have a file called "zoeken.php"
with the code in it as mentioned above!

And yes, I did put some <td></td> cells in there as well, but they're
"code-less", so I felt no need to bother any reader with that! ;-)

The code does change the variable "select_id", so when I manually submit
the form, using the submit button, after clicking on one of the <tr>'s,
the clicked <tr> is selected. But I want my form to submit in the
onClick event! :-)

Anybody?!?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 23 '05 #6
I have had this problem for several years an only just figured out how
to deal with it. There day I got this idea to check all of the
attributes of the from I was calling submit() on from a javascript
function. Low and behold.. Many of the attributes were blank. I've
had forms[].method, forms[].enctype, forms[].action all be empty and so
when you call forms[].submit(), nothing happens. I don't understand
why this happens either because those values are set in my <form> tag,
and somehow get lost. So my fix is to set them in the javascript
function if they are empyt.

For instance:

if( document.forms[index].action == "" )
document.forms[index].action = "multipart/form-data";
document.forms[index].submit();

It works so long as the action, method, and enctype are set.
It's also possible that some of the data you want in your <input> tags
isn't set as you expected. Check those as well if you have further
problems.

-Dieter

Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Xeon | last post by:
Ok, the subject seemed not PHP related, but it does, as the submitted form will be read/processed by PHP. I have this HTML code: <form method="post" action="foo.php"> <select name="blah"...
12
by: Barnes | last post by:
Does anyone know of a good way to use the JavaScript string.replace() method in an ASP form? Here is the scenario: I have a form that cannot accept apostrophes. I want to use the replace() so...
3
by: news.onetel.net.uk | last post by:
I and my friend Karl have spent literally all day trying to find out what is causing my error but we are zapped of any further functionality :) I have a form that adds news records. You select...
2
by: Radu Ciurlea | last post by:
Hello. I want to make the browser show some suggestions under a text box (like the To: field in webmail interfaces that displays addresses in the addressbook). Basically whenever something changes...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
6
by: b. hotting | last post by:
Hi, I don't see why this won't work, it are 3 links, the last one (a get) does work, but the first 2 won't. i would like to use a post, through hidden input types any idea? thanks for your...
8
by: Grant Merwitz | last post by:
hi I am using Javascript to do my validation This is so i can display a loading message after a form is submitted. Now, currently i do so like this. I have a button, textbox and label like...
5
by: rocknbil | last post by:
Hello everyone! I'm new here but have been programming for the web in various languages for 15 years or so. I'm certainly no "expert" but can keep myself out of trouble (or in it?) most of the time....
16
by: browntown | last post by:
so I have this application I'm nearly finished with. The only thing the client has requested is the ability to submit the form by pressing "enter". I didn't think this would be a huge pain in the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.