Dropdown text instead of option value

teranetmk 15 Jul, 2011
Hello there, I was searching the forum for solution to the following problem but i can't seem to find the answer. I have form which has dropdown and Im sending option value to the paypal and email to me. But since I have different prices i need in email to get text from selected value. Here is example which i found on the forum.

  <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 19</option>
          <option value="2">Chapter 10</option>
        </select>
      </div>
      <div class="cfclear"> </div>
    </div>


And in On Submit before
<?php
$chapter = JRequest::getInt('chapter', '', 'post');
JRequest::setVar('chapter_name', 'Chapter '.$chapter);
?>

Then i will get Chapter 1 in email or Chapter 2.
What i need to get is Chapter 19 or Chapter 10

Any advice I would appreciate
Thank you
GreyHead 15 Jul, 2011
Hi teranetmk ,

Which version of ChronoForms are you using? You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6.

Bob
teranetmk 15 Jul, 2011
Hello Im using Chrono Contact V 3.2

Thank you
GreyHead 17 Jul, 2011
Hi teranetmk,

You can add some code in the OnSubmit Before Email box to look up the values to use in the email:
<?php
$chapter_array = array(
  1 => 'Chapter 19',
  2 => 'Chapter 10'
);
$chapter = JRequest::getInt('chapter', '', 'Post');
$chapter_name = $chapter_array[$chapter];
JRequest::setVar('chapter_name', $chapter_name);
?>
Then you can use {chapter_name} in the email template.

Bob
teranetmk 17 Jul, 2011
Yes GreyHead that is solution.

Thank you!
This topic is locked and no more replies can be posted.