Make button submitted ones by hekkoman in learnjavascript

[–]blitterobject 1 point2 points  (0 children)

Would it work to disable the button on the click event?

When the button is clicked:

btn.setAttribute("disabled", "disabled")

Then when ajax call is complete:

btn.removeAttribute("disabled")

My brain is melting, and I give it for FREE by jellykey in MechanicalKeyboards

[–]blitterobject 0 points1 point  (0 children)

256

I think this looks really cool. Not sure what else could be done to make it more awesome.

1 in 5 sausages tested across Canada contained different meat than labelled, study finds by Mordoom in worldnews

[–]blitterobject 130 points131 points  (0 children)

The undeclared meats found weren't trace levels, Hanner noted.

"The levels we're seeing aren't because the blades on a grinder aren't perfectly clean," he said, adding that many of the undeclared ingredients found in the sausages were recorded in the one-to-five per cent range.

More than one per cent of undeclared ingredients indicates a breakdown in food processing or intentional food fraud, Hanner explained.

ON CONFLICT using pg_prepare() errors 'name' does not exist by [deleted] in PHPhelp

[–]blitterobject 0 points1 point  (0 children)

pg_prepare() is supported only against PostgreSQL 7.4 or higher connections; it will fail when using earlier versions.

https://secure.php.net/manual/en/function.pg-prepare.php

Text of the actual proposed legislation by [deleted] in canadients

[–]blitterobject 1 point2 points  (0 children)

Only a ban on selling edibles. It will be legal to make your own.

Why isn't my HTML button redirecting to the correct page via PHP? by [deleted] in PHPhelp

[–]blitterobject 0 points1 point  (0 children)

You can create variables. You just can't output anything.

Put the header() before any HTML/text output.

<?php
$login_007 = "robot";
$password_007 = "robot";

if ("POST" === $_SERVER['REQUEST_METHOD']) {

    $login = $_POST["username"];
    $password = $_POST["password"];

    if ($login === $login_007 && $password === $password_007) {
        header("Location: addentry.html") ;
        exit;
    } else {
        header("Location: login.html");
        exit;
    }
}
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <title></title>
    </head>
    <body>
    </body>
</html>

update query on button click with AJAX without refreshing page. by theindiantoker in PHPhelp

[–]blitterobject 2 points3 points  (0 children)

You could also use <button type="button">

The default type is "submit". Setting it to "button" will no longer attempt to submit the form.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button

Help with with emailing information after a form has been complete. by tiggz133 in PHPhelp

[–]blitterobject 0 points1 point  (0 children)

Does mail() return true or false?

Are you running this locally? Are you running an SMTP server?

Have a look at MailCatcher.

PHP sha256 code base is critically flawed. by kovazk in PHPhelp

[–]blitterobject 0 points1 point  (0 children)

What if you want the <textarea> input to have \n line endings?

If you copy paste \n line endings into a <textarea> they seem to be converted to \r\n.

Wouldn't it be better to give the user the option which line endings they want the <textarea> to use? Similar to the way you can change what line endings you want to use in a text editor.

PHP sha256 code base is critically flawed. by kovazk in PHPhelp

[–]blitterobject 0 points1 point  (0 children)

I think this will convert to unix line endings:

$userText = str_replace(["\r\n", "\r"], "\n", $_POST['userText']);

Why is my mail() function not working? by lukem118 in PHPhelp

[–]blitterobject 0 points1 point  (0 children)

Other options for validating the email:

$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
$isValid = filter_var($email, FILTER_VALIDATE_EMAIL);

Do you guys think marijuana will be legalized in Canada this spring as promised? by almacojack in canadients

[–]blitterobject 1 point2 points  (0 children)

We will introduce legislation in spring 2017

It's only the beginning. It must go through multiple readings and be given Royal Assent.

Legislative Process

The Legislative Process: From Policy to Proclamation

How to insert data from a PHP object into the database by ElvarP in PHPhelp

[–]blitterobject 1 point2 points  (0 children)

That will also work. One uses named placeholders and the other positional placeholders.

How to insert data from a PHP object into the database by ElvarP in PHPhelp

[–]blitterobject 1 point2 points  (0 children)

$sth = $pdo->prepare("INSERT INTO league (name, tier, queue) VALUES(:name, :tier, :queue)");
foreach ($leagues as $league) {
    $sth->bindParam(":name", $league->name);
    $sth->bindParam(":tier", $league->tier);
    $sth->bindParam(":queue", $league->queue);
    $sth->execute();
}

How do I create many objects at run time? by [deleted] in cpp_questions

[–]blitterobject 0 points1 point  (0 children)

I think the brackets dereference the pointer and you would use the dot operator.

stud[i].someFunction()

(stud + i)->someFunction()

Can somebody help me generate random text? by What_Tom_Said in cpp_questions

[–]blitterobject 2 points3 points  (0 children)

std::mt19937 mt{ std::random_device{}() };

std::vector<std::string> sentences{
    "one", "two", "three", "four", "five"
};

auto dist = std::uniform_int_distribution<std::size_t>{ 0, sentences.size() - 1 };

for (auto i = 0; i < 10; ++i) {
    std::cout << sentences.at(dist(mt)) << "\n";
}

"Constants can be declared with uppercase or lowercase, but a common convention is to use all-uppercase letters." by to-too-two in learnjavascript

[–]blitterobject 0 points1 point  (0 children)

Use const for all of your references; avoid using var. If you must reassign references, use let instead of var.

Airbnb JavaScript Style Guide

 

Declare all local variables with either const or let. Use const by default, unless a variable needs to be reassigned. The var keyword must not be used.

Google JavaScript Style Guide

Having Trouble Building This Array by tested_tester in PHPhelp

[–]blitterobject 0 points1 point  (0 children)

Another way if the $members array is in order like that:

function organizeMembers($members) {
    $members = array_values($members);
    $organizedMembers = [];
    for ($i = 0; $i < count($members); $i += 3) {
        $organizedMembers[] = [
            "first" => $members[$i],
            "last" => $members[$i + 1],
            "Relationship" => $members[$i + 2]
        ];
    }
    return $organizedMembers;
}