I'm trying to add a div with some details of a discount coupon so the user can confirm it before I add it to the shopping cart.
The code to the button etc... is this, and it works if I place on the website:
<div class="simpleCart_shelfItem"><h1 class="item_name">Discount of 30%!</h1>Confirm Coupon!<span class="item_price" >0.00€</span></div>
Then, I tried to dynamically add the code (when a php post confirms that the coupon code is OK) using jQuery, but by some strange reason it doesn't work.
I managed to write this:
$('div.cupao_confirm').html('<div class="simpleCart_shelfItem"><h1 class="item_name">Discount of 30%!</h1>Confirm Coupon!<span class="item_price" >0.00€</span></div>');
Without jQuery the code add the "0.00€" product to the shopping cart, so I can later send the equivalent money back to the buyer. With jQuery when I click on the link nothing happens at all. So it's not a jQuery related problem... I might be doing the .html() wrong... :( help!
Thanks!
try to use the append() method :
$('div.cupao_confirm').append("<div class="simpleCart_shelfItem"><h1 class="item_name">Discount of 30%!</h1>Confirm Coupon!<span class="item_price" >0.00€</span></div>");
Give it a try and let me know if it worked, Thanks.
I think maybe you need to re-initialize simple cart ager changing the shell contents. Try:
simpleCart.init();
Related
Im trying to find a selector to the following button:
Inspecting Button
I need this for a Puppeteer headless chrome task.
e.g.: await page.waitForSelector(The selecor comes here);
The site: https://www.notebooksbilliger.de/
The button appears after adding a random product to cart and then redirect to: https://www.notebooksbilliger.de/kasse/anmelden
Would appreciate some help, wasted many hours trying to solve this :)
Since, there is no specific id to select. Here I'm trying with href attribute.
buttons = document.querySelectorAll("a[href='https://www.notebooksbilliger.de/kasse/unregistriert']");
Now, you can do any script work with
buttons[0]
back again! been a while.
So this is my question.
I have a datatable set up that gets the information from the database and shows this in a modal (bootstrap4).
That works fine by the way, but now I wan't to add a dropdown option.
This dropdown needs to have information that is stored in the database (just one table with all the rows).
success:function(data){
$('#Modal').modal('show');
$('#Id').val(data.id);
$('.number').html("<select><option>".val(data.number)"</option></select>");
$('#skills').val(data.skills);
$('.modal-title').html("<i class='edit'></i> Edit ");
$('#action').val('Data');
$('#save').val('Save');
}
as you can see I tried to do this little trick but sadly it didn't take so I was wondering if something like this is even possible?
Thanks so much for the help/info.
Assuming that your modal already contains a select box in a .number div with several options in it then the following would add the extra option into it, generated from the data object:
$('.number select').append(`<option value="${data.number}">${data.number}"</option>`);
long-time lurker here asking my first public questions because I am truly stuck.
I'm working on a hosted shopping cart platform so I only have access to add code in certain designated divs. I have a javascript code that I'm calling externally (because inline is bad unless you have to, right?)
So my issue is, There is a <select> dropdown that I do NOT have direct access to change HTML and the silly shopping cart platform didn't give it an id, only the name attribute is set.
I need to clear the <div id="result_div"> when the <select name="ShippingSpeedChoice"> drop-down is clicked so I have:
$("[name=ShippingSpeedChoice]").change(function(e) {
$("#result_div").empty();
});
It fires once, but that's it. My question is, how do I make it fire EVERY TIME the <select name="ShippingSpeedChoice"> is clicked?
Here's all the relevant javascript (in case it's preventing #result_div from clearing somewhere):
$("[name=ShippingSpeedChoice]").change(function(e) {
$("#result_div").empty();
});
$("#btn_calc").click(function(e) { /// onclick on Calculate Delivery Date button
Thanks in advance, any help is appreciated!
If you want something to happen every time the element is clicked, use .click() rather than .change(). The latter only fires if they select a different value from the menu than it had before.
$("[name=ShippingSpeedChoice]").click(function(e) { $("#result_div").empty(); });
First of all, I'd probably try and setup the shopping cart select to have an id.
$("[name=ShippingSpeedChoice]").id = 'shopping_cart_select';
then try binding the "change" function to the element via it's id.
$('#shopping_cart_select').bind('change', function(){
//rest of code goes here
}
I still wasn't able to use the name attribute to call the function, so I found a way around it by using the id of the td the ShippingSpeedChoice dropdown was in:
$("#DisplayShippingSpeedChoicesTD").change(function(e) {
$("#result_div").empty();
And it fires every time now. Thank you so much for all your feedback & assistance - I still wish I could figure out how to use the name attribute rather than the id, but that will be a puzzle for another day!
I have a SharePoint list with the following single line of text fields: Title, Year and Type or Location. I want to be able to hide the Type or Location table row in the default display form. I know that I should create a JavaScript script and put it in Content Editor web part inside DispForm.aspx.
I am not fluent with jQuery syntax, thus I need help with the code, i.e. I don't know how to reference the table row which contains Type or Location field and its value. Here's what I've done so far, but it doesn't work:
jQuery(document).ready(function($) {
$("input[title='Type or Location']").closest("tr").hide();
});
I know that the "input[title='Type or Location']" part is incorrect; at least I think it's that. Could anyone help me out? Thank you.
Try:
jQuery(document).ready(function($) {
$("h3.ms-standardheader:contains('Type or Location')").closest("tr").hide();
});
I am not sure why you want to use jQuery for that. In SharePoint, you can choose to make a field required, optional or hidden. In most cases, just switching to hidden will address your issue.
For the record, I would also try to avoid as much as possible the use of jQuery(document).ready, it might conflict with the SharePoint out of the box onload event. In your case it is not needed.
Update: here is a way to do this with jQuery:
$("td.ms-formlabel:contains('Type or Location')").parent().hide();
Try it this way:
jQuery(document).ready(function($) {
$("input[title='Type'],input[title='Location']").closest("tr").hide();
});
It depends what type of column Type ior Location is. If it's a Single line of text, then you're close. You should use a DOM inspector like IE's Developer Tools or Firebug to see what the actual title of the input element is.
If the column is a different type, then it's likely not an input element. Using the DOM inspector again, you can look at what elements make up the field control and decide on your selector from that.
Finally, remember that hiding things in script is not secure. A savvy user can turn off the script or otherwise change the script so that they can edit it. It all depends on your requirements.
// UPDATE //
Ah, you said DispForm. As was pointed out in another answer, there aren't any input elements in a DispForm. You need to correct your selector.
If its just the Default Display Form, How about just creating a view and making it default?
The syntax should be like this:
$("input[title='Type']").closest("tr").hide();
$("input[title='Location']").closest("tr").hide();
It will work.
Whats wrong with this function?
function yahooWeather(){
var loadPage = 'yahooweather.php?p='+ $("#myCity").val();
$("#yahoo").html('<img src="loading.gif" align="absmiddle">');
$("#yahoo").load(loadPage);
}
Is there another way to write this function. Im unsure if its able to read the .val required, tho i know it is set as i used it in a previous function to test that it was being set, so im thinking its maybe my load call.
http://www.wetterkanal.tv/
This is the page. This function once called by clicking the button, should get the value set by the "select city" option then load the weather in a div below. I have set the css to this div as green so i know it loads. I also know that my php script works as if i test it by going to the following:
http://wetterkanal.tv/yahooweather.php?p=ASXX0001
it pulls the weather in correctly. Please help!
Your problem is that the button element will reload the page when the button is clicked.
You need to change your onclick attribute to onclick="yahooWeather(); return false;".