Avoid page refresh and add values to javascript session? [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to add two products to comparison queue like on this site (http://www.phonearena.com/phones/manufacturers/Samsung) Here if you hover on a mobile phone and click on 'compare+' it add to a java-script or browser session and if you open another page and click on next any mobile 'compare+' button, it adds up to the comparison queue, which you can later use to compare two mobiles.
I want to know what should I do, to achieve this functionality. My web app is being developed in MVC3 and I want to compare two of my products this way.
Please I just need some help how to figure this out.
Thanks

Here is how you would use cookies:
document.cookie = "mobile1=" + mobile1;
and then you can retrieve it like so:
mobile1 = document.cookie

Give
http://plugins.jquery.com/cookie/
a try. Something like:
if ($.cookie("choices"))
{
// have previous choice, so handle comparison display and reset state
// ...
$.removeCookie("choices");
}
else
{
$.cookie("choices", "key of first product");
}

Related

boostrap hide/show buttons based on variable [closed]

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 (trying) to build an app based on boostrap/javascript/ and a nosql DB
a sort of small CRM/invoicing system
i need to show/hide button based on variable
for example for a quote, status could be "open", "lost" "win"
so on my quote details page when status of quote is open i want to show button
- win (who change status of quote id in db to win and copy quote to an order)
- lost (who change status of quote id in db)
but i want to hide button "Re-open" who change a cancel status to open
and so on for my different status..
so want i'm looking for is a way to collapse/hide some button depending of the status of my quote (i put the status of my quote in a variable called quoteStatus)
any suggestion will be welcome
thanks
jeebee
You can do something like that
if (quoteStatus==="value"){
document.getElementById("buttonId").style.display='none';
}
else{
document.getElementById("button").style.display='block';
}
this is just javascript, you could use jquery it will make it easier for you, so your code may look like that
if (quoteStatus==="value"){
$("#buttonId").hide();
}
else{
$("#buttonId").show();
}
To get more positive reactions to your question you have to show some research effort. This question is not useful in that mather that you havent actually showed us what you have tried, and the purpose of your functionality have possibly been asked and explained before? How to hide/show div based on variable using javascript. A div and a button is both elements.
Either way, as for your question, we need to know what you already have. The task in itself have several ways to be accomplished, and based on your existing code there could be a way to complete this task in a more correct manner than others.

Knockout Editing with asp.net roles [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm a newbie to knockout and was wondering what the best approach using knockout with asp.net membership roles (mvc 4), I want to add a grid on the page and make it editable if the user is an administrator or just make it viewable if they are in a 'registered user' role? I don't want the user to be able to edit the page by changing the javascript using developer tools/firebug unless the only way to stop that is to check for role when post results back.
Thanks in advance, hope that makes sense.
You wouldn't use knockout for this. If a user is not an admin, they should not even be able to reach the page. Just use the [Authorize] attribute at the controller or the action level and specify what roles are allowed. Any JavaScript solution could easily be worked around given any industrious user access to user management despite their role.

PHP Cookies using Variable from URL form google campaign [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to add a parameter to all URLs that we use in our campaigns adwords.
Can you help me in that sense?
You've just written your code in explanations. What is the problem to make the explanations in code? Is there something more that the mentioned?
if(isset($_GET['refid']) && $_GET['refid'] == 'adwords') {
setcookie('refid', $_GET['refid'], time()+3600*24*30);
}
if(isset($_COOKIE['refid']) && $_COOKIE['refid'] = 'adwords') {
//display tel number
}
You just need exactly that - if the get parameter exists - assign cookie. If cookie exists - display. It's simple conditions in PHP. If it's only this - you need to learn the basics in PHP.

Javascript datepicker inside prompt [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I've never seen it before, but I reckon it can be done.
I'm making an application right now, and I use a prompt in javascript to get the requried data, like
description = prompt ("insert your description here, please");
Now, we want to be able to retrieve a date from a datepicker inside this prompt.
So, prompt comes up, asks for a description, you fill in your description, click ok, and then another prompt box comes up with a datepicker. That's the idea, but it seems impossible to achieve.
Can someone guide me to the right direction?
It looks like a modal dialog would be more appropriate than a form:
http://jqueryui.com/dialog/#modal-form

unidentified javascript function [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I've been handed a role administering a SharePoint site, and the following custom code is on one of the pages:
<script type="text/javascript">
$(document).ready(function() {
$("#pgtitle").html("Customer Service Feedback");
});
</script
I'm not a javascript guy, so I'm having trouble interpreting this. The code was written by someone who is no longer with my firm, and left well before I arrived.
$(document).ready(function() means that the code that follows, will start as soon as the page has loaded.
$("#pgtitle").html("Customer Service Feedback"); simply passes the value Customer Service Feedback to the HTML element pgtitle.
if you look on the page for the pgtitle element, I'm sure you will see it contains the text Customer Service Feedback ! :)
It sets text on the element of id = pgtitle as soon as the DOM document had fully loaded. In human language it manually sets the value of some title.
Have a look at the JQuery library for the "html" method and if you look for the id that is called "pgtitle" you will find the html that is effected.
Source:http://api.jquery.com/html/

Categories