I looked in the issue area for something that looked like it related to my question but I either don't know what terms to use or no one has really asked about it.

I have one select field called country where users need to pick their country. Then I have another field down farther was has to do with some engineering type stuff that has to have the same input as the country field. Is there a way that when they select a country, it pre-populates the other field below it?

I tried using this code here to at least ensure the same answer was typed in but it isn't working:

<?php
  if ($form_values['submitted_tree']['country'] != $form_values['submitted_tree']['preferred_wri_code']) {
    form_set_error('submitted][country', t('These country codes do not match.  They must match before you can submit your form.'));
  }
?>

Not sure why....

Becky

Comments

benone’s picture

Hi, I am looking exactly the same option but for CCK form fields.
I have address, then I have another address field. I would like to copy the address from one field to another or put different address.
Anyway, subscribe.

quicksketch’s picture

Status: Active » Closed (fixed)

Support for writing custom code is not provided in the Webform issue queue. Just a note that if you're using the 3.x version and have multiple pages, you can prepopulate the second field with the new %value token.

beckyjohnson’s picture

Oh ok, thanks for the tip about the %value token.