Note that there are some explanatory texts on larger screens.

plurals
  1. POColdFusion: Add CFSELECT dynamically to document with the push of a button
    primarykey
    data
    text
    <p>Right now I am on a project with a merchant solution service on the back end. Unfortunately I goofed up. Initially we didn't think we would have to populate any form fields that we 'generated' after the site had loaded. So I simply used some javascript to create additional form entries with the click of a button. This worked fine, and we could use anything the user put in there to upload to the database from ColdFusion.</p> <p>But our management did not give us proper design requirements. He just came back and said "Ok, now just add some drop downs so they can select the version". I think you can see the problem here. Now we need to populate <em>some</em> of the dynamic form fields with information from the server. Ergo a client side solution is now basically down the crapper. </p> <p>So I come to for you help friends. Is there a way to still retain the functionality of what I've done with the JS with a ColdFusion equivalent? I know that there must be, but I'm trying to find a simple conversion. </p> <p>Here's how the addInput.js file looks:</p> <pre><code>// JavaScript Document var counter = 0; var UID = counter + 1; var limit = 3; function addInput(divName){ if (counter == limit) { alert("You have reached the limit of adding " + counter + " inputs"); } else { var newdiv = document.createElement('div'); newdiv.innerHTML = "&lt;input type='hidden' value='new' name='Detail_ID'&gt;" + "&lt;input type='text' value='' name='level' maxlength=255 PASSTHROUGH='style=width:640;color:#editcolor#' TABINDEX='5'&gt;" +"&lt;input type='text' value='' name='offer' maxlength=255 PASSTHROUGH='style=width:640;color:#editcolor#' TABINDEX='5'&gt;" +"&lt;input type='text' value='' name='disclaimer' maxlength=255 PASSTHROUGH='style=width:640;color:#editcolor#' TABINDEX='5'&gt;"; "&lt;CFSELECT NAME = 'version_no' QUERY = VersionList VALUE = 'code' DISPLAY = 'description' SELECTED = #version_no# &gt;&lt;/CFSELECT&gt;" document.getElementById(divName).appendChild(newdiv); counter++; } } </code></pre> <p>And here is the button which creates it on the main .cfm page:</p> <pre><code>&lt;input type="button" value="Add Another VIP Level" onClick="addInput('dynamicInput');"&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload