You are viewing our Forum Archives. To view or take place in current topics click here.
PhP help with POST requests
Posted:
PhP help with POST requestsPosted:
Status: Offline
Joined: Nov 28, 20149Year Member
Posts: 21
Reputation Power: 0
Hey, I've created a slider that uses JavaScript and HTML, I want to be able to send this value to another PhP script that I've written using POST, how'd I go about this, I know I'd need to use HTML forums, but I'm not really sure how I'd implement them into this, I also need it to send the post data for the value and a file, I already have the file working but I have no idea how to send the 18+ since it's value is stored in JavaScript. Here's the code,
HTML:
<div class="toggle-box"><div class="toggle-button" onclick="toggleSlider(this);"><div class="slider"></div></div> 18+ only</div><br>
JavaScript:
var pluschecked = false;
function checkPlus() {
if(pluschecked==false) {
document.getElementById("et").innerHTML = "";
pluschecked = true;
} else {
document.getElementById("et").innerHTML = "";
pluschecked = false;
}
}
function openUpload() {
document.querySelector(".pblanket").style.display = "block";
document.querySelector(".popup").style.display = "block";
}
function closeUpload() {
document.querySelector(".pblanket").style.display = "none";
document.querySelector(".popup").style.display = "none";
}
function colorPlaceholder() {
document.querySelector("placeholder").style.color = "#0BE";
}
function uncolorPlaceholder() {
document.querySelector("placeholder").style.color = "#000";
}
var toggled = false;
function toggleSlider(e) {
if(toggled==false) {
e.querySelector(".slider").style.left = "47.5%";
e.querySelector(".slider").style.borderTop = "2px solid #0D0";
toggled = true;
} else {
e.querySelector(".slider").style.left = "2.5%";
e.querySelector(".slider").style.borderTop = "2px solid #D00";
toggled = false;
}
}
HTML:
<div class="toggle-box"><div class="toggle-button" onclick="toggleSlider(this);"><div class="slider"></div></div> 18+ only</div><br>
JavaScript:
var pluschecked = false;
function checkPlus() {
if(pluschecked==false) {
document.getElementById("et").innerHTML = "";
pluschecked = true;
} else {
document.getElementById("et").innerHTML = "";
pluschecked = false;
}
}
function openUpload() {
document.querySelector(".pblanket").style.display = "block";
document.querySelector(".popup").style.display = "block";
}
function closeUpload() {
document.querySelector(".pblanket").style.display = "none";
document.querySelector(".popup").style.display = "none";
}
function colorPlaceholder() {
document.querySelector("placeholder").style.color = "#0BE";
}
function uncolorPlaceholder() {
document.querySelector("placeholder").style.color = "#000";
}
var toggled = false;
function toggleSlider(e) {
if(toggled==false) {
e.querySelector(".slider").style.left = "47.5%";
e.querySelector(".slider").style.borderTop = "2px solid #0D0";
toggled = true;
} else {
e.querySelector(".slider").style.left = "2.5%";
e.querySelector(".slider").style.borderTop = "2px solid #D00";
toggled = false;
}
}
#2. Posted:
Status: Offline
Joined: May 02, 201212Year Member
Posts: 1,129
Reputation Power: 34
Status: Offline
Joined: May 02, 201212Year Member
Posts: 1,129
Reputation Power: 34
I'm confused (and so is everyone on here)... can you reword this if you haven't figured it out?
Since you already have the variable in javascript then set up a function in javascript that sends the data over via post.
So in this function:
- Create a form
- Set action
- Set method (post)
- Make the inputs hidden
- Submit form
Then for the html
This is just an idea
Since you already have the variable in javascript then set up a function in javascript that sends the data over via post.
So in this function:
- Create a form
- Set action
- Set method (post)
- Make the inputs hidden
- Submit form
myform = document.createElement('form');
myform.action = 'actionpage.php';
myform.method = 'POST';
input1 = document.createElement('input');
input1.type = 'hidden';
input1.name = 'name';
input1.value = '18+'; //the value of the variable
myform.appendChild(input1);
document.getElementById('hidden_slider').appendChild(myform);
theForm.submit();
Then for the html
<div id="hidden_slider" style="display:none;"></div>
This is just an idea
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.