Forums

Text instead of value using double dropdown

remi20 27 Apr, 2011
Hi all,

I was wondering if it is possible to get the text instead of the values in confirmation page and email when using a double dropdown.

This is the code I use, found it here on the forums:

    <div class="form_item">
      <div class="form_element cf_dropdown">
        <label class="cf_label"
          style="width: 150px;">Chapter</label>
        <select class="cf_inputbox" id="chapter" size="1"
          title="" name="chapter">
          <option value="">Choose Option</option>
          <option value="1">Chapter 1</option>
          <option value="2">Chapter 2</option>
        </select>
      </div>
      <div class="cfclear"> </div>
    </div>

    <div class="form_item">
      <div class="form_element cf_dropdown">
        <label class="cf_label"
          style="width: 150px;">Recipe</label>
        <select class="cf_inputbox" id="recipe" size="1"
          title="" name="recipe">
    <optgroup label="Chapter 1" id="ch_1"
        disabled="disabled" >
      <option value="a">Recipe a</option>
      <option value="b">Recipe b</option>
      <option value="c">Recipe c</option>
    </optgroup>
    <optgroup label="Chapter 2" id="ch_2"
        disabled="disabled" >
      <option value="x">Recipe x</option>
      <option value="y">Recipe y</option>
      <option value="z">Recipe z</option>
    </optgroup>
      </div>
      <div class="cfclear"> </div>
    </div>

    <div class="form_item">
      <div class="form_element cf_button">
        <input value="Submit" name="submit"
          id="submit" type="submit" />
      </div>
      <div class="cfclear"> </div>
    </div>

window.addEvent('load', function() {
  var num_groups = 2
  var groups = new Array;
  for ( var i = 1; i <= num_groups; i++ ) {
   groups[i] = $('ch_'+i);
   $('ch_'+i).remove();
  }
  $('chapter').value = '';

  $('chapter').addEvent('change', function() {
    var group_no = $('chapter').value;
    if ( !group_no ) {
      return;
    }
   $$('#recipe optgroup').each(function(el) {el.remove()});
   $('recipe').appendChild(groups[group_no]);
  });
});


Basically if I could get 'Chapter 1' or 'Chapter 2' in my email instead of just '1 or 2'. Then it would be easy for me to edit to my liking.

Is there any easy way around this? I pretty much have zero knowledge about this, therefore any help is highly appriciated.

I would like to thank you guys for a wonderful extension!
Best Regards
GreyHead 05 May, 2011
Hi remi20,

In the OnSubmit Before box you can 'edit' the value from the form. I'd advise using a new variable for the Chapter name:
<?php
$chapter = JRequest::getInt('chapter', '', 'post');
JRequest::setVar('chapter_name', 'Chapter '.$chapter);
?>
Then use {chapter_name} in your email template.

Bob
This topic is locked and no more replies can be posted.