mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
893 B
42 lines
893 B
6 years ago
|
<script>
|
||
|
let questions = [
|
||
|
{ id: 1, text: `Where did you go to school?` },
|
||
|
{ id: 2, text: `What is your mother's name?` },
|
||
|
{ id: 3, text: `What is another personal fact that an attacker could easily find with Google?` }
|
||
|
];
|
||
|
|
||
|
let selected;
|
||
|
|
||
|
let answer = '';
|
||
|
|
||
|
function handleSubmit() {
|
||
|
alert(`answered question ${selected.id} (${selected.text}) with "${answer}"`);
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<h2>Insecurity questions</h2>
|
||
|
|
||
|
<form on:submit|preventDefault={handleSubmit}>
|
||
1 year ago
|
<select value={selected} on:change={() => (answer = '')}>
|
||
6 years ago
|
{#each questions as question}
|
||
|
<option value={question}>
|
||
|
{question.text}
|
||
|
</option>
|
||
|
{/each}
|
||
|
</select>
|
||
|
|
||
1 year ago
|
<input bind:value={answer} />
|
||
6 years ago
|
|
||
1 year ago
|
<button disabled={!answer} type="submit"> Submit </button>
|
||
6 years ago
|
</form>
|
||
|
|
||
4 years ago
|
<p>selected question {selected ? selected.id : '[waiting...]'}</p>
|
||
|
|
||
|
<style>
|
||
|
input {
|
||
|
display: block;
|
||
|
width: 500px;
|
||
|
max-width: 100%;
|
||
|
}
|
||
1 year ago
|
</style>
|