Dynamic text in email

jkerr 09 Feb, 2011
Yet another question!

I have set text to change what it shows depending on what the user selects in a drop down menu. I am unsure how to get the email to show the dynamic text. The default is £0 and the auto generated email template sends £0 as text rather than the ID number. I have set the ID of the text to "price" and thought {price} in the email template should work, but it doesn't.

Any ideas?

Cheers.
GreyHead 09 Feb, 2011
Hi Jkerr

The {price} syntax is linked to the input 'name', not the 'id'. Does that help?

Bob
jkerr 09 Feb, 2011
I am quite confused now.

Code is
<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Organisation Income</label>
    <select class="cf_inputbox validate-selection"  id="select_34" size="1" title="" onChange="cost()" name="select_34">
    <option value="">Choose Option</option>
      <option value="101">£0-£25k</option>
<option value="102">£25,001-£50k</option>
<option value="103">£50,001-£100k</option>
<option value="104">£100,001-£500k</option>
<option value="105">£500,001-£1m</option>
<option value="106">£1m-£5m</option>
<option value="107">£5m+</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_text"> <div id="price"> <span class="cf_text">Your membership will cost £0.</span> </div> </div>
  <div class="cfclear"> </div>
</div>



Then for javascript to change the text


function cost()

{
var a = document.getElementById("select_34").value;

if (a == 101)
{
document.getElementById("price").innerHTML = "Your membership will cost £0";
}

if (a == 102)
{
document.getElementById("price").innerHTML = "Your membership will cost £15";
}

if (a == 103)
{
document.getElementById("price").innerHTML = "Your membership will cost £25";
}

if (a == 104)
{
document.getElementById("price").innerHTML = "Your membership will cost £40";
}

if (a == 105)
{
document.getElementById("price").innerHTML = "Your membership will cost £55";
}

if (a == 106)
{
document.getElementById("price").innerHTML = "Your membership will cost £55";
}

if (a == 107)
{
document.getElementById("price").innerHTML = "Your membership will cost £55";
}
}



So I want the line "Your membership will cost £XX" to appear in the email. Is there an ID automatically created for text you add in via the wizard I could use?
GreyHead 09 Feb, 2011
Hi jkerr,

The only info that is returned when the form is submitted is from inputs, selects and textareas. The text in your span will only be shown on the webpage.

You have two main choices. You can re-calculate the value using PHP in the OnSubmit Before box (similar to the lookup for the select value); or you can alter your script to save the value in a hidden input that will be submitted.

Add this to the Form HTML
<input type='hidden' name='save_price' id='save_price' value='' /> 
and alter the script like this example
if (a == 101)
{
document.getElementById("price").innerHTML = "Your membership will cost £50";
document.getElementById("save_price").value = "Your membership will cost £50";
}

Bob

PS In practice I'd probably just pass the 50 in the save_price variable and add the rest of the text in the Email template.
jkerr 09 Feb, 2011
Like I said in the other thread, you are a genius! Thank you for all of the help.
This topic is locked and no more replies can be posted.