boostrap hide/show buttons based on variable [closed] - javascript

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.

Related

How to make next page link when document size reaches to specific length? [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 6 years ago.
Improve this question
I have built an Admin section where i can see all the contents from database in a table. everything is fine but if the database table has thousands of rows I have to scroll down very deep. is there any way I can make links like `1,2,3.Next the way google search results do? or is there any even better way?
Isn't is going to be something like:
if($(document).height>2000){
//what should i do?
}
Looks like you are using jquery. If you are going to implement everything on your own it may be time consuming - although it would be fun!
To save some time, there are quite a few plugins available to achieve this. Refer:
https://datatables.net/
http://www.jqueryscript.net/table/Client-side-HTML-Table-Pagination-Plugin-with-jQuery-Paging.html
Since you may have huge data you should be using server side pagination instead of client side. Here is another SO link which explains the difference between them : Pagination: Server Side or Client Side?

Browsing a database as the user is typing [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
This is probably a simple question, but I'm struggling with this.
Basically, how to browse in a database, as the user is typing something?
For example, in a website such as https://www.doesthedogdie.com/, how do they do it to show all the movies beggining with the string of characters you're typing, as you're typing it?
I guess javascript is involved?
It's called autocomplete
Please do some googling next time yourself.
You can use jQuery autocomplete or Bootstrap typeahead to achieve this.
Hope this helps
My personal preference on how to make these kind of systems is fairly awkward, yet it seems to work just fine for me without requiring too much client-side scripting.I use ASP.NET's Page_Load event to save all content in a SQL database into an XML file. Then, when the user enters some text into the field, I make a hidden div class underneath it unhidden to display filtered results from the XML document. This way, you can update the SQL database at any time fairly simply to add new records which should be listed on the website.This is server-side scripting, which I prefer to client-side because the user can disable features and mess around with it to view your code which is something I personally hate.I hope this helps you somewhat.

PHP saving and re fetching checkbox values [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 am an electronic engineering student. I have a doubt concerning Web development. I have to make a web site for doctors to enter patients data. Most of the data are in check box format. My question is regarding saving and re fetching check box status from the data base, so that the user can see what all are checked previously and what all are not checked when he log's in back the next time.
And also how can i replace the check-box status in database if i change the status. I searched about this in internet but there is no much data concerning this. So if anyone could guide me or give me a link or example codes where i can look and study, it will be a great help for me.
You can save the values of a particular check box in many different way and there are tons of resources online for this, I am sure you have come accross this information before.
You could save your check box values as a string with a string delimiter, for example: A-B-C-D-E. This was you can split/explode the string whenever you need to retrieve the values again as an array and appropriately mark the corresponding check boxes once they sign in again.
Some Resources: http://www.html-form-guide.com/php-form/php-form-checkbox.html
send checkbox value in PHP form

How to make a password that unlocks with buttons clicked in a specific order [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 8 years ago.
Improve this question
I've recently created a few piano keys using HTML, CSS and some Javascript and I would like to know how to go about creating a password that only unlocks when certain keys are played in a specific order.
I imagine the code would go something like:
if (correct sequence of keys are input) {
unlocks secret content;
}else{
message: try again!;
}
I've never made a password lock of any kind and I'm not sure what language would be idea for a password... Ideally it would word in browsers and on phones. I'm really new to javascript and I know that people can easily see your code so I guess I can't really use that because people would look for the password. Any ideas/guidance would be greatly appreciated!
If you don't want users to see the login credentials, you'll need to include some server side code with PHP, or ASP.NET for example so that the check is done on the server and not in the users browser.
But otherwise it would be fairly simple to do this piano key check by making each click on the buttons add a new character to a string.
var pw="";
document.getElementById('key1').onclick=function(){pw +="x"};
And then just do a standard check on that string to a saved password.

asp.net mvc a grid of results with close buttons [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Currently converting an old asp.net web forms page into a asp.net mvc version, and a little stuck on something that isn't a major deal, but would be a nice to have.
When the user logs in, they are taken to a messages page at /Alerts. They can close individual messages by clicking the x's, and then if they close all the message they are moved onto another page automatically.
The original site did postbacks, so the URL stayed the same. In my new version, I planned to make the x button a link, that went to /Alerts/Confirm/xx where xx is the id. The problem is, after processing, the address bar stays on that url, whereas I'd like to leave it on /Alerts
The four solutions appear to be either:
1) using AJAX to do the processing;
2) a redirect back to /Alerts after processing;
3) replacing all the X links with a submit button, and using javascript to pass a different ID depending on which message is being acknowledged, so that I can change the Confirm method to an HttpPost-accepting Index method?
4) URL Rewrites? (not sure about this, just thought of as I wrote this)
Or am I missing something obvious that would do what I'm trying to achieve?
I agree with #1 and use Jquery to do it.
Or you could show/hide those messages using Jquery .show() .hide(). So, they would always be there, just hidden. When they hit refresh they would show again.
You can also use some sort of notification plugin for jquery, there are many available just google for it, this page has about 6 examples, it is a bit old but you can get an idea.

Categories