By brauhaus on
Hi
I have created a webform with a few radio buttons, a few text fields and an email field. On the bottom of the form there is one last option: "No thank you,
I will not attend the event
I would like to receive the pressfolder"
It are checkboxes. What I'm looking for is a way to tell the form that when the first checkbox is selected the rest of the form (or even better, parts of it) should be reset. I've been looking all over for an answer but no luck. I'm quite new to php, but learning fast. Any tips?
thank you.
Comments
javascript
Filling out a form happens on the client side (in the visitor's browser) which means that all php scripts have already finished their job (sending a web page to the visitor). In other words, what you want to do, cannot be done with php. Fortunately, there is javascript. Drupal has jQuery (a javascript library) built in, which means that you can code javascript behavior with only a couple of lines.
For more information, start reading http://api.drupal.org/api/file/developer/topics/javascript_startup_guide... and have a look at the jquery documentation at http://docs.jquery.com/, or feel free to ask further questions.
thank you!
thank you!
not working
ok, I tought I was getting close,
I found this http://drupal.org/node/192280, but it is not working for me, I think everything is installed (jquery update, php input filter), I've checked the id's with firebug... but I'm stuck.
It seems like the slash between the words "spreker/panelleden" and the "(" break the string.
The other lines work just fine.
any suggestions? tnx
it's not unlikely that those
it's not unlikely that those characters are the problem. Can you post a link? it's easier for me to help you if I see the page itself.
An illegal choice
please take a look.
http://www.freethefuture.be/?q=inscriptions
http://www.freethefuture.be/?q=inschrijven
I got my English form working and part of my dutch form. De French one is a mess
when I want to submit I get this message
"An illegal choice has been detected. Please contact the site administrator. "
And it does not react at all to the jquery script.
I don't see a problem (in
I don't see a problem (in Firefox and Opera on Linux), did you fix it in the mean time, or didn't I look well enough?
Anyway, in the webform module, you can change a field's form key in the advanced settings fieldset at the bottom of the field edit page. By altering the form key, you can make those ID's much shorter and cut out all characters that are a possible problem.
If you
If you visit
http://www.freethefuture.be/?q=inscriptions
and select one of the checkboxes under "no merci", the fields above should be disabled.
I'm using firefox and safari on a mac and it doesn't react.
If I'm right I can only alter the form field ID and not the form field component ID that is called in the javascript. And it seems that calling the Form field id does not work.
here is the adjusted code.
Those special characters,
Those special characters, like the é, are indeed the problem. I did a quick test in Firefox+Firebug which showed that
$("#edit-submitted-keuzefr-je-souhaite-obtenir-une-interview-avec-lun-des-orateurs-ou-invités");did not return the object with that id, but after changing the id of that input to "edit-submitted-keuzefr-je-souhaite-obtenir-une-interview-avec-lun-des-orateurs-ou-invites",$("#edit-submitted-keuzefr-je-souhaite-obtenir-une-interview-avec-lun-des-orateurs-ou-invites");seemed to work fine.Have you already tried to edit the form keys as I suggested in my previous message? I think that simplifying those ID's is an important step in solving this. Another way to simplify your code would be to select a couple of inputs at once, for instance:
$("#webform-component-keuzefr input")would select all input tags inside div#webform-component-keuzefr.Using smarter selectors, your script could be as compact as this:
However, I think you would still have to change the form keys to get rid of the special characters in "#edit-submitted-non-merci-Je-ne-participerai-pas-à-l\'événement-Free-the-Future".
thank you for your help, I've
thank you for your help,
I've solved it with a work around and created custom pages, where it is a lot easier to rename the componements.
How to select all fields or only input fields of a form by jQuer
STEP 1:
Disabling all elements including text, hidden, radio, checkbox, submit, textarea, select of form
$('form :input').attr('disabled','disabled');
Here i am selecting form by tag '
' without using any id or class of form.
STEP 2:
Disabling only input fields including text, hidden, radio, checkbox, submit of form
$('form input').attr('disabled','disabled');
STEP 3:
Disabling some particular inputs like only text fields or check boxes etc.
$('form input[type=text]').attr('disabled','disabled');
$('form input[type=text], input[type=checkbox]').attr('disabled','disabled');