Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm have planned to design a jewelry website with add to cart option. but i still don't know how to keep the selected items on the cart even after refreshing the page through jquery. so if anyone knew please provide an step by step example or tutorial.
You can use a simple JQuery get method which links to a PHP file which adds the product to the Site cookies; when you want to view the cart, explode the cookie.
An example:
$(document).ready(function(){
$("#product").click(function(){
// However you want to get the item ID
var itemID = document.getElementById("productID").value;
$.get("/inc/addtocart.php", { item: itemID }, function(data){
document.getElementById("result-sec").innerHTML=data;
});
});
});
Your PHP file will look like this:
if(isset($_GET['item'])){
$_COOKIE['cart_ids'] = $_COOKIE['cart_ids'] . '::' . $_GET['item'];
}
To view your cart items, simply:
$all_items = explode("::", $_COOKIE['cart_ids']);
foreach($all_items as $item):
echo $item . "<br />";
endforeach;
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
there is a simple order page on my website that I have prepared to improve myself.
When the order page is opened ,the" 1 piece " option is selected.
Do this " document.getElementById ('mark1').click () " I did it thanks to this code. But when you click on 1pc, you will see that it comes in their products.
My request is that 1 option is selected when the site is opened and the products are listed. How can I do this?
Page: https://fcproje.com/nike/siparis.php
Clicking that <input type='radio'> seems to trigger the following code on line 598 of your file
$("#mark1").on('click', function() {
var markalar = this.dataset.id;
var mainid=1;
if(markalar){
for (var i =1; i <= mainid; i++) {
sender(i,markalar);
}
}
});
You could simulate this code after the code you use to click on the radio button.
So change this line
document.getElementById('mark1').click()
To this block of code;
document.getElementById('mark1').click();
(function(){
var markalar = "1"; // The Dataset.id of the input was "1" so add it here
var mainid=1;
if(markalar){
for (var i =1; i <= mainid; i++) {
sender(i,markalar);
}
}
})();
The code is wrapped in an anonymous function as to not add unnecessary variables to the global window object.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a small project where i created text fields based on user input.
$('#arraySizeButton').click(function() {
var arraySize = $("#arraySize").val();
if(arraySize=='') {
alert("Enter Some Text In Input Field");
}else{
var count = arraySize;
var html = [];
while(count--) {
html.push("\<input type='text' id='inputTextField", count, "'>");
}
$('#inputTextFieldsarea').append(html.join(''));
}
});
I want to create a dynamic program based on above code and retrieve data from textfields to an array. Appreciate your help.
Did you mean this?
html.push("<input type='text' id='inputTextField"+count+"'/>");
What you should do is add a [] to the name of the input, to let the html form know that this is an array.
You should do something like that:
html.push("\<input name='field[]' type='text' id='inputTextField", count, "'>");
And using php to get the content of all the POSTed fields you could simply check
$_POST['field']
which is an array.
EDIT: IF you want to do this using jquery as you stated in your comment, then you could do it like that:
$('[id^="inputTextField"]').each(function() {
alert($(this).val());
});
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
<?php
if (isset($_POST['submit']))
{
$username=$_POST['username'];
$url=$_POST['url'];
$bank=$_POST['bank'];
$namarekening=$_POST['namarekening'];
$norekening=$_POST['norekening'];
$nohape=$_POST['nohape'];
$email=$_POST['email'];
$anda=$_POST['anda'];
mysql_query("insert into users (username,email,namarekening,norekening,nohape,anda,url,bank)
values('$username','$email','$namarekening','$norekening','$nohape','$anda','$url','$bank')
")or die(mysql_error());
?>
<script>alert('Successfully Registered!'); window.location = 'pesarta.php';</script>"
<?php
}
?>
This is my code, any idea what should i do, i make table with 3 column, No.,URL, and the other one is Status. i want if they send, it automatically fill up the Status table with pending..
in your mysql table (users) set a default value pending for field status
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to delete a row from table with delete button with confirmation from user but without page refreshing with help of jQuery ajax.
I know a little about php, html, javascript, jquery, and sql. I dont know how to go about doing this but what i really want to do is to be able to pull data from a sql table (i already know how to do this).
Then display the data with a button next to it (i also already know how to do). When they click the button it will remove the element that hold the visible data and also send a sql statment to delete the row in the database. A very crude code over view.
<?php
echo '<p>Data 1: '".$someDataFromDB."'<button id='deleteThisRow'></button></p>;
?>
from this I would like to:
Click the button
remove the paragraph element so they users know it was deleted
then send an sql statement to delete the row from the sql table
All this without refreshing the page. Is that at all possible?
Yes it is possible but you should only send the id of the entry to a particular page to delete the entry.never the entire sql statement.
<button id="<?php echo $row['id']; ?>" class="delbutton"></button>
add this script to your page
<script type="text/javascript" >
$(function() {
$(".delbutton").click(function() {
var del_id = $(this).attr("id");
var info = 'id=' + del_id;
if (confirm("Sure you want to delete this post? This cannot be undone later.")) {
$.ajax({
type : "POST",
url : "delete_entry.php", //URL to the delete php script
data : info,
success : function() {
}
});
$(this).parents(".record").animate("fast").animate({
opacity : "hide"
}, "slow");
}
return false;
});
});
</script>
and last but no the least your delete script
<?php
include 'connection.php';
$id=$_POST['id'];
$delete = "DELETE FROM table WHERE id=$id";
$result = mysql_query($delete) or die(mysql_error());
?>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am new in this world...so please help..I want idea from u people...I have 4 dropdown list ..and I wanted to populate select box on selecting another selectbox2 .... using database values....so how should I proceed ..i need your help...and i have already created the database for that...and I am good with database....so please help me..forward me some link also..I have short span of time..within that i have to complete..please help.
In Spring 3.0 you can populate values in the dropdown as follows:
#ModelAttribute("webFrameworkList")
public List<String> populateWebFrameworkList() {
//Data referencing for web framework checkboxes
List<String> webFrameworkList = new ArrayList<String>();
webFrameworkList.add("Spring MVC");
webFrameworkList.add("Struts 1");
webFrameworkList.add("Struts 2");
webFrameworkList.add("JSF");
webFrameworkList.add("Apache Wicket");
return webFrameworkList;
}
In JSP
<form:select path="favFramework">
<form:options items="webFrameworkList"/>
</form:select>
Now you can modify the logic as per your requirement that you want.