Forms and input

Automatic Draft Survey Form for Follow-up Responses

Complete an auto-draft form for a follow-up survey scenario: includes real content, interactive controls, clear status feedback, and responsive layouts.

Forms and inputAuto Draft FormHTMLCSSJavaScript
With JavaScript enabled, you can edit, run, and save this example. The fixed source is as follows:
<!doctype html>
<html lang="en" dir="ltr">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Automatic Draft Survey Form for Follow-up Responses</title>
  <style>
    :root { --ink:#ecf7f3; --paper:#071310; --accent:#af4f45; --secondary:#9eb49f; --line:color-mix(in srgb, var(--ink) 18%, transparent); --shadow:0 24px 60px color-mix(in srgb, var(--ink) 16%, transparent); color-scheme:light; }
    * { box-sizing:border-box; }
    html { min-width:320px; background:var(--paper); }
    body { min-height:100vh; margin:0; overflow-x:hidden; color:var(--ink); font-family:ui-monospace,"SFMono-Regular",Consolas,monospace; background:linear-gradient(color-mix(in srgb,var(--secondary) 5%,transparent) 1px,transparent 1px),linear-gradient(90deg,color-mix(in srgb,var(--secondary) 5%,transparent) 1px,transparent 1px),var(--paper);background-size:24px 24px; }
    button,input,select,textarea { color:inherit; font:inherit; }
    button,[role="button"],input,select,textarea { accent-color:var(--accent); }
    button { cursor:pointer; }
    button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,[tabindex]:focus-visible { outline:3px solid var(--accent); outline-offset:3px; }
    [hidden] { display:none !important; }
    @media (max-width:700px) { .mast h1 { line-height:1.08 !important; letter-spacing:-.035em !important; overflow-wrap:anywhere; } }
    @media (prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior:auto !important; animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; } }
    .page{width:min(1080px,calc(100% - 30px));margin:auto;padding:48px 0}.eyebrow{color:var(--secondary);font:700 12px/1.3 ui-monospace,monospace}.eyebrow::before{content:"> ";color:var(--accent)}.mast{display:grid;grid-template-columns:1fr auto;border:1px solid var(--secondary);padding:18px;gap:24px;align-items:center;margin-bottom:16px}.mast h1{font-family:ui-monospace,"SFMono-Regular",monospace;font-weight:700;font-size:clamp(34px,7vw,72px);letter-spacing:-.055em;margin:12px 0;line-height:1.05}.intro{margin:0;color:color-mix(in srgb,var(--ink) 72%,transparent);font:400 14px/1.7 ui-monospace,monospace}.scenario{padding:7px 10px;border:1px dashed var(--secondary);font:700 11px/1 ui-monospace,monospace}.demo{border-color:var(--secondary);border-radius:8px;box-shadow:0 0 50px color-mix(in srgb,var(--secondary) 15%,transparent);position:relative;min-height:390px;padding:26px;background:color-mix(in srgb,var(--paper) 94%,#000)}@media(max-width:700px){.page{width:calc(100% - 18px);padding:20px 0}.mast{grid-template-columns:1fr}.demo{padding:14px}}
    .panel{padding:26px;border:1px solid var(--line);border-radius:2px;background:var(--paper)}.stack{display:grid;gap:28px}.row{display:flex;gap:20px;flex-wrap:wrap}.action{padding:9px 2px;border:0;border-bottom:2px solid var(--line);background:transparent}.action.primary,.action.is-active{border-color:var(--accent);color:var(--accent)}.muted{font-size:14px;line-height:1.9}.status{min-height:20px;margin-top:28px;font-size:13px}.metric{font-size:clamp(40px,9vw,88px);font-weight:500;letter-spacing:-.06em}.meter{height:2px;background:var(--line)}.meter>i{display:block;height:100%;background:var(--accent)}.chip{font-size:11px;letter-spacing:.12em;text-transform:uppercase}
    .composition-split{display:grid;grid-template-columns:150px minmax(0,1fr);gap:18px;align-items:start}.split-note{position:sticky;top:20px;display:grid;gap:14px;padding:18px 12px;border-block:3px double var(--accent);font-size:13px;line-height:1.65}.split-note b{font:900 12px/1 ui-monospace,monospace;letter-spacing:.12em}.split-note span{writing-mode:vertical-rl;min-height:120px;color:color-mix(in srgb,var(--ink) 60%,transparent)}.composition-split .demo{min-width:0}@media(max-width:900px){.composition-split{grid-template-columns:1fr}.split-note{position:static;grid-template-columns:auto 1fr}.split-note span{writing-mode:horizontal-tb;min-height:0}}
    .draft-editor-lab{display:grid;gap:18px;max-width:920px;margin:auto}.draft-editor-lab header{display:flex;justify-content:space-between;gap:18px;align-items:end}.draft-editor-lab h2{margin:.3em 0}.draft-editor-grid{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(220px,.85fr);gap:18px}.draft-main,.draft-sidebar{display:grid;gap:14px}.draft-main label{display:grid;gap:8px;font-weight:800}.draft-main input,.draft-main textarea{width:100%;padding:14px;border:1px solid var(--line);border-radius:12px;background:var(--paper);font:inherit}.draft-main textarea{line-height:1.8;resize:vertical}.draft-sidebar{align-content:start;padding:18px;border:1px solid var(--line);border-radius:18px;background:color-mix(in srgb,var(--secondary) 10%,var(--paper))}.draft-sidebar strong{font-size:32px}.draft-sidebar ol{display:grid;gap:7px;padding-left:20px;margin:0}.draft-editor-lab output{color:var(--accent);font-size:13px}@media(max-width:720px){.draft-editor-lab header{align-items:stretch;flex-direction:column}.draft-editor-grid{grid-template-columns:1fr}}.workflow-compare{display:grid;grid-template-columns:minmax(230px,.55fr) minmax(0,1.45fr);gap:18px}.compare-stage{display:grid;gap:12px;min-width:0}.compare-stage>header{display:flex;justify-content:space-between;gap:16px;align-items:end}.compare-stage h2{margin:.2em 0}.compare-core{--compare-split:50%;min-width:0;padding:14px;clip-path:inset(0 calc(100% - var(--compare-split)) 0 0);outline:1px dashed var(--accent);outline-offset:-8px;transition:clip-path .25s,filter .25s}.compare-core[data-compare-channel="B"]{filter:hue-rotate(32deg) saturate(1.15)}.compare-controls{display:grid;align-content:start;gap:16px;padding:20px;border:1px solid var(--line);border-radius:24px 4px 24px 4px;background:var(--paper)}.compare-controls fieldset,.compare-controls>label{display:grid;gap:8px}.compare-controls input[type="range"]{width:100%}#workflowCompareShelf{display:grid;gap:6px;padding:0;margin:0;list-style:none}#workflowCompareShelf li{display:grid;grid-template-columns:auto 1fr auto;gap:8px;padding:9px;border-top:1px solid var(--line);font-size:12px}@media(max-width:900px){.workflow-compare{grid-template-columns:1fr}.compare-stage{order:-1}.compare-core{clip-path:none;border-left:8px solid var(--accent)}}
  </style>
</head>
<body data-aesthetic="terminal" data-composition="split-note">
  <main class="page">
    <header class="mast"><div><span class="eyebrow">terminal / Auto Draft Form / ADVANCED</span><h1>Automatic Draft Survey Form for Follow-up Responses</h1><p class="intro">Complete an auto-draft form for a follow-up survey scenario: includes real content, interactive controls, clear status feedback, and responsive layouts.</p></div><span class="scenario">Follow-up Questionnaire</span></header>
    <div class="composition-split"><aside class="split-note"><b>CASE 02</b><span>Master the semantic structure, responsive composition, keyboard interaction, and state synchronization of an auto-draft form.</span></aside><section class="demo" aria-label="Follow-up questionnaire auto-draft form interaction area"><div class="workflow-compare"><form id="workflowCompareControls" class="compare-controls"><fieldset><legend>Reference Channel</legend><label><input type="radio" name="workflowChannel" value="A" checked>A · Follow-up questionnaire basic information</label><label><input type="radio" name="workflowChannel" value="B">B · Follow-up questionnaire supplementary materials</label></fieldset><label>Processing Time Weight<input id="workflowCompareWeight" type="range" min="10" max="90" value="50"><output id="workflowCompareWeightValue">50 hours</output></label><label><input id="workflowCompareFreeze" type="checkbox">Freeze current version</label><button id="workflowCompareCapture" class="action primary" type="button">Sample and confirm submission</button><ol id="workflowCompareShelf" aria-label="Version Sampling Record"></ol></form><section class="compare-stage"><header><span class="eyebrow">Follow-Up Questionnaire COMPARE</span><h2>Post-visit survey dual-version comparison</h2><output id="workflowCompareLive">Version A waiting for sampling</output></header><section id="workflowCore" class="workflow-core compare-core" data-compare-channel="A" style="--compare-split:50%"><!-- 11DZ_CORE_START:forms-input-draft-editor --><section class="draft-editor-lab"><header><div><span class="eyebrow">LOCAL DRAFT</span><h2>Follow-up Questionnaire Draft Board</h2><p>The title, body, and saved records all stay only in the local browser.</p></div><output id="draftState">Not entered yet</output></header><div class="draft-editor-grid"><div class="draft-main"><label>Draft Title <input id="draftTitle" type="text" maxlength="24" placeholder="Enter the title for this draft"></label><label class="draft-body">Body <textarea id="draftText" rows="10" placeholder="Content will be saved automatically in your local browser"></textarea></label></div><aside class="draft-sidebar"><strong id="draftWordCount">0 bytes</strong><p id="draftSyncHint">Waiting for auto-save</p><ol id="draftTimeline"><li>Open the page to restore your most recent draft</li><li>After saving, the current word count and time will be shown</li></ol><div class="row"><button id="saveDraft" class="action primary" type="button" data-core-bridge="forms-input-draft-editor">Save now</button><button id="clearDraft" class="action" type="button">Clear draft</button></div></aside></div></section><!-- 11DZ_CORE_END --></section></section></div><p id="status" class="status" role="status" aria-live="polite"></p></section></div>
  </main>
  <script>
    'use strict';
    const statusOutput = document.querySelector('#status');
    const announce = message => { statusOutput.textContent = message; };
    /* 11DZ_CORE_SCRIPT_START:forms-input-draft-editor */
const draftTitle=document.querySelector('#draftTitle');const draftText=document.querySelector('#draftText');const draftState=document.querySelector('#draftState');const draftWordCount=document.querySelector('#draftWordCount');const draftSyncHint=document.querySelector('#draftSyncHint');const draftTimeline=document.querySelector('#draftTimeline');const draftKey='forms-input-draft-editor-feedback-intake:draft';let draftTimer=null;function renderDraftMeta(savedLabel='Waiting for auto-save'){const count=draftText.value.trim()?draftText.value.trim().split(/\s+/).join('').length:draftText.value.length;draftWordCount.textContent=count+' Characters';draftSyncHint.textContent=savedLabel;}try{const stored=JSON.parse(localStorage.getItem(draftKey)||'null');if(stored){draftTitle.value=stored.title||'';draftText.value=stored.body||'';draftState.textContent=stored.body?'Local draft restored':'Not entered yet';}}catch{draftState.textContent='The current environment does not allow persistent saving';}function saveLocalDraft(){clearTimeout(draftTimer);try{const payload={title:draftTitle.value,body:draftText.value,savedAt:new Date().toLocaleTimeString('zh-CN',{hour:'2-digit',minute:'2-digit'})};localStorage.setItem(draftKey,JSON.stringify(payload));draftState.textContent='Saved automatically';renderDraftMeta('Recently saved '+payload.savedAt);const item=document.createElement('li');item.textContent=(payload.title||'Untitled Draft')+' · '+payload.savedAt;draftTimeline.prepend(item);while(draftTimeline.children.length>4)draftTimeline.lastElementChild.remove();announce('Draft saved locally');}catch{draftState.textContent='Unable to write to local storage';renderDraftMeta('Draft saving is not supported in the current environment');announce('Draft saving is not supported in the current environment');}}function queueDraftSave(){draftState.textContent='Waiting for auto-save';renderDraftMeta('Waiting for auto-save');clearTimeout(draftTimer);draftTimer=setTimeout(saveLocalDraft,450);}draftTitle.addEventListener('input',queueDraftSave);draftText.addEventListener('input',queueDraftSave);document.querySelector('#saveDraft').addEventListener('click',saveLocalDraft);document.querySelector('#clearDraft').addEventListener('click',()=>{draftTitle.value='';draftText.value='';try{localStorage.removeItem(draftKey);}catch{}draftState.textContent='Draft cleared';renderDraftMeta('Cleared');announce('Draft cleared');});renderDraftMeta();
/* 11DZ_CORE_SCRIPT_END */
const workflowBridgeSpec={"name":"forms-input-draft-editor","selector":"[data-core-bridge=\"forms-input-draft-editor\"]","mode":"click","key":"Enter"};const workflowBridgeCore=document.querySelector('#workflowCore');const workflowBridgeControl=workflowBridgeCore.querySelector(workflowBridgeSpec.selector);if(!workflowBridgeControl)throw new Error('Missing core bridge: '+workflowBridgeSpec.name);const workflowBridgeControlledId=workflowBridgeControl.getAttribute('aria-controls');const workflowBridgeControlled=workflowBridgeControlledId?document.getElementById(workflowBridgeControlledId):null;workflowBridgeCore.dataset.workflowBridge=workflowBridgeSpec.name;workflowBridgeCore.dataset.workflowVersion='0';function workflowBridgeSerialize(){const visualNode=workflowBridgeCore.firstElementChild||workflowBridgeCore;const visual=getComputedStyle(visualNode);const outputs=[...workflowBridgeCore.querySelectorAll('output,[role="status"],[aria-live],meter,progress')].map(node=>node.textContent.trim()+'|'+node.getAttribute('aria-valuenow')+'|'+node.getAttribute('value'));const canvas=[...workflowBridgeCore.querySelectorAll('canvas')].map(node=>{try{return node.toDataURL().slice(-160);}catch{return 'canvas-unavailable';}});return JSON.stringify({html:workflowBridgeCore.innerHTML,status:statusOutput.textContent,outputs,canvas,visual:[visual.display,visual.visibility,visual.opacity,visual.transform,visual.filter,visual.backgroundColor,visual.width,visual.height],scroll:workflowBridgeSpec.mode==='scroll'?workflowBridgeControl.scrollTop:null});}let workflowBridgeLastEffect=workflowBridgeSerialize();function workflowBridgeSummary(){const label=(workflowBridgeControl.getAttribute('aria-label')||workflowBridgeControl.textContent||workflowBridgeControl.value||workflowBridgeSpec.name).trim().replace(/\s+/g,' ').slice(0,72);return label+' · Core Version '+workflowBridgeCore.dataset.workflowVersion;}function workflowBridgeCommit(){const effect=workflowBridgeSerialize();if(effect===workflowBridgeLastEffect)return {changed:false,summary:workflowBridgeSummary()};workflowBridgeLastEffect=effect;workflowBridgeCore.dataset.workflowVersion=String(Number(workflowBridgeCore.dataset.workflowVersion||0)+1);return {changed:true,summary:workflowBridgeSummary()};}function workflowBridgeScheduleCommit(){queueMicrotask(workflowBridgeCommit);setTimeout(workflowBridgeCommit,0);}workflowBridgeControl.addEventListener("click",workflowBridgeScheduleCommit);const workflowBridgeStateTargets=new Set(workflowBridgeCore.querySelectorAll('dialog'));if(workflowBridgeControlled&&workflowBridgeCore.contains(workflowBridgeControlled))workflowBridgeStateTargets.add(workflowBridgeControlled);workflowBridgeStateTargets.forEach(target=>['close','cancel','toggle'].forEach(eventName=>target.addEventListener(eventName,workflowBridgeScheduleCommit)));function workflowBridgeActivate(){workflowBridgeControl.focus();workflowBridgeControl.click();const result=workflowBridgeCommit();setTimeout(workflowBridgeCommit,0);return result;}function workflowBridgeReset(){workflowBridgeCore.dataset.workflowVersion='0';workflowBridgeLastEffect=workflowBridgeSerialize();}
const workflowCompareCore=document.querySelector('#workflowCore');const workflowCompareWeight=document.querySelector('#workflowCompareWeight');const workflowCompareState={channel:'A',weight:50,frozen:false,snapshots:[]};function workflowCompareFingerprint(){const controls=[...workflowCompareCore.querySelectorAll('input,select,textarea')];const outputs=[...workflowCompareCore.querySelectorAll('output,[role="status"],strong')].map(node=>node.textContent.trim()).filter(Boolean);return {controlValues:controls.map(control=>control.type==='checkbox'||control.type==='radio'?control.checked:control.value),summary:outputs.slice(0,4).join(' / '),nodes:workflowCompareCore.querySelectorAll('*').length};}function workflowCompareDrive(){workflowCompareCore.dataset.compareChannel=workflowCompareState.channel;workflowCompareCore.style.setProperty('--compare-split',workflowCompareState.weight+'%');document.querySelector('#workflowCompareWeightValue').textContent=workflowCompareState.weight+' hour';document.querySelector('#workflowCompareLive').textContent=workflowCompareState.channel+' Version · '+workflowCompareState.weight+' hour'+(workflowCompareState.frozen?' · Frozen':'');announce('The follow-up questionnaire is being viewed '+workflowCompareState.channel+' Version');}function workflowCompareCapture(source){const bridge=workflowBridgeActivate();const snapshot={...workflowCompareFingerprint(),channel:workflowCompareState.channel,weight:workflowCompareState.weight,source,bridge:bridge.summary};workflowCompareState.snapshots.push(snapshot);const item=document.createElement('li');item.innerHTML='<b>'+snapshot.channel+'</b><span>'+(snapshot.summary||snapshot.bridge)+'</span><small>'+snapshot.weight+' hours · '+snapshot.bridge+'</small>';document.querySelector('#workflowCompareShelf').prepend(item);announce('sampled '+snapshot.channel+' Version and confirm submission · '+bridge.summary);}document.querySelectorAll('[name="workflowChannel"]').forEach(input=>input.addEventListener('change',()=>{workflowCompareState.channel=input.value;workflowCompareDrive();}));workflowCompareWeight.addEventListener('input',()=>{workflowCompareState.weight=Number(workflowCompareWeight.value);workflowCompareDrive();});document.querySelector('#workflowCompareFreeze').addEventListener('change',event=>{workflowCompareState.frozen=event.currentTarget.checked;workflowCompareDrive();});document.querySelector('#workflowCompareCapture').addEventListener('click',()=>workflowCompareCapture('Button Sampling'));workflowCompareCore.addEventListener('dblclick',()=>workflowCompareCapture('Main view double-click'));workflowCompareDrive();
workflowBridgeReset();
  </script>
</body>
</html>
Page feedbackFound an issue or have suggestions for improvement?
Feedback features need to be used in the online version

Please enable JavaScript in the online version before submitting; local features of the current tool or example are not affected.

Go to the online version for feedback