Forums

Building a diyamic link based on customer choises.

spinarenato@tin.it 20 Jun, 2012
Hi All
I need to build a dynamic link to allow the customers to download a pdf file.
The dynamic part of the Pdf file name is a "colour" + a "number" that customers have to select in the form, like the following image.


This is the code I used in the HTML form (CF V3):

<label class="cf_label" style="width: 150px;">Choise your color</label>
<select class="cf_inputbox validate-selection" id="select_1" size="1" title=""  name="colors" type="text" onChange="updatethis(this.form);" value=""/>
    <option value="">seleziona</option>
      <option value="white">white</option>
<option value="red">red</option>
<option value="blu">blu</option>
    </select>
<br />
<label class="cf_label" style="width: 150px;">Choise your number</label>
<select class="cf_inputbox validate-selection" id="select_2" size="1" title=""  name="numbers" type="text" onChange="updatethis(this.form);" value=""/>
    <option value="">seleziona</option>
      <option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
    </select>
<br />
<input style="background-color: #f0f0f0; border-color: #f0f0f0; text-align: center;" class="cf_inputbox" maxlength="200" size="80" title="" id="text_2" name="link" type="text" value="" readonly="readonly"/>


This is the code that I used in the JS form.

function updatethis(form) {
      form.elements['link'].value = '<a href="file/'+form.elements['colors'].value+form.elements['numbers'].value+'.pdf">Download your file!</a>';
}

It's ok, I was able to "build" the link but is not Hypertext. Maybe there is a specific function in JS, I don't know. Could someone give me some help?

Thank you very much in advance.
Max_admin 27 Jun, 2012
Hi,

What about using something like:
form.elements['link'].href
or
$('LINK_ID').set('href', 'test.com');


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.