-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
104 lines (87 loc) · 3.29 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html>
<head>
<title>Vue.js Forn Builder</title>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Styles -->
<style type="text/css">
html,body,.jumbotron{background-color: #41b883 }
.container{width: 95%}
.jumbotron{padding: 10px;max-width: 600px; margin: 0 auto; text-align: center}
.form-render{background-color: rgba(0,0,0,.2); color: #fff;}
</style>
</head>
<body>
<div class="container" id="formBuilder">
<div class="row">
<div class="col-xs-12">
<div class="jumbotron">
<h1 class="primary-color">VUE.JS Form Builder!</h1>
<p>This is a form builder created completely with Vue.js. Feel
free to fork it, scrap it, extend it, imrpove it, but mostly have fun with it</p>
</div>
</div>
<!-- FORM BUILDER -->
<section class="form-builer col-xs-12 col-sm-6">
<div class="form-group">
<label>Question Type:</label>
<select v-model="preForm.type" class="form-control">
<option value="" selected>Select Type</option>
<option value="text">Text</option>
<option value="textarea">Textarea</option>
<option value="dropdown">Dropdown</option>
<option value="radio">Radio</option>
<option value="checkbox">Checkbox</option>
</select>
</div>
<template v-if="preForm.type !== null && preForm.type !== '' && preForm.type !== undefined">
<div class="form-group">
<label>Questin Name:</label>
<input v-model="preForm.label" type="text" class="form-control">
<template v-if="preForm.type === 'dropdown' || preForm.type === 'radio'">
<div class="form-group">
<label>Option:</label><input class="form-control" type="text" v-model="option">
</div>
<div class="form-group">
<span v-on="click: addOption()" class="btn btn-primary">Add Option</span>
</div>
<ol><li v-repeat="preForm.answers">{{$value}}</li></ol>
</template>
</div>
<div class="form-group">
<span v-if="preForm.label !== null" v-on="click: addToForm()" class="btn btn-default">Add To Form</span>
</div>
</template>
</section>
<!-- RENDER FORM -->
<section v-if="form.length > 0" class="form-render col-xs-12 col-sm-6">
<div v-repeat="form">
<div class="form-group">
<label>{{label}}:</label>
<!-- Text -->
<input v-if="type === 'text'" type="text" name="{{label}}" class="form-control">
<!-- Textarea -->
<textarea v-if="type === 'textarea'" name="{{label}}" class="form-control"></textarea>
<!-- Dropdown -->
<select v-if="type === 'dropdown'" class="form-control">
<option>Select</option>
<option v-repeat="answers" value="{{$value}}">{{$value}}</option>
</select>
<!-- Radio -->
<template v-if="type === 'radio'">
<br>
<span v-repeat="answers">
{{label}} <input type="radio" name="{{label}}" value="{{$value}}">
</span>
</template>
<!-- Checkbox -->
<input v-if="type === 'checkbox'" type="checkbox" name="{{label}}">
</div>
</div>
</section>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/0.12.10/vue.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>