Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Sumitting Check Boxes - Help please!!

Status
Not open for further replies.

JonMusto

Programmer
Aug 3, 2004
34
GB
Hi Folks,

I'm trying to create a form with a number of checkboxes, that once changed automatically submit the form. I have the following:

<form id="enquiry" name="enquiry" action="" method="post">
<input type="checkbox" name="1" class="chk" value="1" onchange="document.enquiry.submit()" />
<input type="checkbox" name="2" class="chk" value="1" onchange="document.enquiry.submit()" />
<input type="checkbox" name="3" class="chk" value="1" onchange="document.enquiry.submit()" />
</form>


The form submits to its self, then basically i'm using php to deal with the resulting $_GET variable.

I've tried various different things, but to no avail, basically only the bottom checkbox works!! Eh!!! And thats only in Firefox, in I.E i get a javascript error.

Does what i'm doing look ok?

thanks in advance for reading this...
 
Don't start your element names with a number. This is illegal syntax.

What you have looks OK... is that a cut-down version of your code? Do you have any other elements in the form (perhaps one named submit)?

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
That is cut down yes... There are various other tags in form for arranging data, such as <p>'s and </p>'s etc.

But no submit button.

I'll try renaming the variables and let you know how it goes...

Cheers.
 
Here is the one of the forms, on a page that has only one checkbox, i've changed the checkbox names to begin with a char and it still doesn't work... Some things just ain't meant to be...:

<form id="enquiry" name="enquiry" action="" method="post" enctype="text/plain">

<h2>Juglans</h2>
<div class="productItem">
<h3>Butternut Walnut</h3>
<p><em>(cinerea)</em></p>
<p class="productDescription">Deciduous, spreading tree bears large, aromatic bright green leaves. Dense clusters of large rounded fruits in autumn. H 80ft S 70ft</p>
<div class="productDetails">
<p class="productRange">Height Range : <span>6-8ft</span></p>
<p class="productRange">Price Range : <span>£50</span></p>

<label class="checkbox">Add to enquiry!
<input type="checkbox" name="prod_id_32" class="chk" value="1" onchange="document.enquiry.submit()" />
</label>

</div>
</div>
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top