addGameJam fix

This commit is contained in:
Jacob Søfeldt 2021-04-26 11:16:37 +02:00
parent 4db2b3d3a3
commit 87830d0a9e
2 changed files with 22 additions and 36 deletions

View File

@ -77,19 +77,16 @@
<div>
<form id="createGameJam" method="POST">
<!-- <label for="nameOfGameJam">Indtast navn på Game Jam:</label>
<input type="text" name="newGameJam" id="nameOfGameJam"> -->
<div class="FormField">
<input
type="text"
class="FormFieldInput"
placeholder="Gamejam title"
name="newGameJam"
id="GamejamTitle"
id="gamejamTitle"
required
/>
<label for="GamejamTitle" class="FormFieldLabel">
<label for="gamejamTitle" class="FormFieldLabel">
Gamejam title
</label>
</div>
@ -122,9 +119,6 @@
</div>
<div class="Times">
<label for="startTime" class="FormFieldLabel" id="startTimeLabel">
Start
</label>
<input
type="text"
class="FormFieldInput"
@ -133,6 +127,9 @@
id="startTime"
required
/>
<label for="startTime" class="FormFieldLabel" id="startTimeLabel">
Start tid
</label>
<input
type="text"
@ -142,6 +139,9 @@
id="endTime"
required
/>
<label for="endTime" class="FormFieldLabel" id="endTimeLabel">
Slut tid
</label>
</div>
</div>
@ -171,12 +171,6 @@
Beskrivelse
</label>
</div>
<!-- <div class="form-floating">
<textarea class="form-control" name="description" id="description" placeholder="Leave a comment here" id="floatingTextarea2" style="height: 100px"></textarea>
<label for="floatingTextarea2">Beskrivelse</label>
</div> -->
<input type="submit" name="newGameJam" id="indsend" value="Indsend" />
</form>
</div>

View File

@ -4,32 +4,24 @@ $(document).ready(function () {
$("#createGameJam").submit(function (e) {
let URL = "/Backend/Controllers/GameJam/NewGameJam.php";
let form = $("#createGameJam")[0];
let formData = new FormData(form);
let id = $("#indsend").attr("name");
let value = $("#indsend").val();
let startTime = $("#startTime").text();
let endTime = $("#endTime").text();
formData.append(id, value);
formData.set("startTime", startTime);
formData.append("endTime", endTime);
const params = new URLSearchParams();
params.append("newGameJam", document.getElementById("indsend").value);
params.append("gameJamName", document.getElementById("gamejamTitle").value);
params.append("startDate", document.getElementById("startDate").value);
params.append("endDate", document.getElementById("endDate").value);
params.append("startTime", document.getElementById("startTime").value);
params.append("endTime", document.getElementById("endTime").value);
params.append("keyWord", document.getElementById("keyWord").value);
params.append("description", document.getElementById("Beskrivelse").value);
axios
.post(URL, formData, {
header: "multipart/form-data",
.post(URL, params)
.then(function (response) {
console.log(response);
})
.then((res) => {
if (res.status === 200) {
console.log("New Game Jam Created!");
}
})
.catch((error) => {
console.log(error.response);
.catch(function (error) {
console.log(error);
});
e.preventDefault();
});
});