Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <form id="form">

  <fieldset cf-questions="Ready to try a conditional flow?">
    <label for="intro-yes">Yes
			            <input type="radio" name="cfc-intro" id="intro-yes" value="yes">
			        </label>

    <label for="intro-no">No thanks
			            <input type="radio" name="cfc-intro" id="intro-no" value="no">
			        </label>

    <label for="intro-disabled">Disabled..
			            <input type="radio" disabled name="cfc-intro" id="intro-disabled" value="ignore">
			        </label>
  </fieldset>

  <input type="text" id="gr8" name="cfc-step1" cf-questions="Conditional flow pre, please write, <strong>gr8</strong> to continue, if you write something else than <strong>gr8</strong> the will you will skip elements." cf-conditional-cfc-intro="yes" />

  <fieldset cf-questions="<strong>{gr8}!</strong> Please choose a path.">
    <input required type="radio" name="cfc-path" id="path-a" value="a" cf-conditional-cfc-step1="^gr8$||great">
    <label for="path-a">Path A</label>

    <input required type="radio" name="cfc-path" id="path-b" value="b" cf-conditional-cfc-step1="^gr8$||great">
    <label for="path-b">Path B (checkboxes and radiobuttons)</label>

    <input required type="radio" name="cfc-path" id="path-d" value="d" cf-conditional-cfc-step1="^gr8$||great">
    <label for="path-d">Path D (C is ignored)</label>
  </fieldset>

  <!--Path A-->
  <input id="path-a-1" type="text" cf-questions="Path A question 1/1, try and change your previous choice to B" cf-conditional-cfc-path="a" />

  <!--Path B-->
  <fieldset cf-questions="Path B question 1/2, multi choice">
    <input required type="checkbox" cf-conditional-cfc-path="b" name="cfc-path-b-checkbox" id="path-b-checkbox-1" value="test1">
    <label for="path-b-checkbox-1">Path B, checkbox 1</label>

    <input required type="checkbox" cf-conditional-cfc-path="b" name="cfc-path-b-checkbox" id="path-b-checkbox-2" value="test2" checked="checked">
    <label for="path-b-checkbox-2">Path B, checkbox 2</label>
  </fieldset>


  <!-- if both checkboxes are checked-->
  <!-- also path b -->
  <!-- two different conditions !-->
  <input id="path-b-alternative" type="text" cf-questions="Both checkboxes checked and path 'b' was choosen, hurray \o/" cf-conditional-cfc-path="b" cf-conditional-cfc-path-b-checkbox="test1,test2" />

  <fieldset cf-questions="Path B question 2/2, radio buttons, <strong>hint:</strong> choose one to continue">
    <input required type="radio" cf-conditional-cfc-path="b" name="cfc-path-b-radio" id="path-b-radio-1" value="test1">
    <label for="path-b-radio-1">Path radio 1</label>

    <input required type="radio" cf-conditional-cfc-path="b" name="cfc-path-b-radio" id="path-b-radio-2" value="test2" checked="checked">
    <label for="path-b-radio-2">Path radio 2</label>
  </fieldset>

  <!--Path C-->
  <input type="text" cf-questions="Path C question 1/1, I will be completly ignored as there is no C Path." cf-conditional-cfc-path="c" />

  <!--Path D, section > option-->
  <select cf-questions="Path D question 1/1, Pick an option." cf-conditional-cfc-path="d" name="path-d-option">
			        <option value="option-a" selected>Path D 2/2 #1</option>
			        <option value="option-b">Path D 2/2 #2</option>
			    </select>

  <input type="text" cf-questions="Path D question 2/2/1" cf-conditional-path-d-option="option-a" />

  <input type="text" cf-questions="Path D question 2/2/22" cf-conditional-path-d-option="option-b" />

  <!-- standard flow, no confitionals -->
  <input id="nope" type="text" cf-questions="You decided not to continue on the conditional adventure, Zelda is sad." cf-conditional-cfc-intro="no" />

  <fieldset cf-questions="I am apart of standard flow, a natural part of the flow. No conditionals involved here.">
    <input required type="radio" name="standard-radios" id="standard-yes" value="a">
    <label for="standard-yes">Standard radio 1</label>

    <input required type="radio" name="standard-radios" id="standard-no" value="b">
    <label for="standard-no">Standard radio 2</label>
  </fieldset>

  <input id="outsider" type="text" cf-questions="Lst step of the flow (not a conditional step)" />
</form>
<div id="cf-context" role="cf-context" cf-context></div>
              
            
!

CSS

              
                #cf-context { 
  width: 100vw; 
  height: 100vh; 
} 
#form {
  height: 0px;
  overflow: hidden;
}
              
            
!

JS

              
                window.onload = function() {
  var testValidation = function(dto, success, error) {
    console.log("dto....", dto, success, error);
    if (dto.text.indexOf("world") != -1) return success();
    return error();
  };

  const dispatcher = new cf.EventDispatcher();
  dispatcher.addEventListener(
    cf.ChatListEvents.CHATLIST_UPDATED,
    function(event) {
      // console.log("chat list updated...", event);
    },
    false
  );

  var conversationalForm = new cf.ConversationalForm({
    formEl: document.getElementById("form"),
    context: document.getElementById("cf-context"),
    eventDispatcher: dispatcher,
    preventAutoFocus: true,
    flowStepCallback: function(dto, success, error) {
      success();
    },
    submitCallback: function() {
      // remove Conversational Form
      alert("You made it!");
      console.log("Form submitted...");
    }
  });
};

              
            
!
999px

Console