Show DIV if input field is >= $row->number

JavaScript and client side scripting.

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Show DIV if input field is >= $row->number

Post by simonmlewis »

No it can't.
If we want the discount to be when they add 20 to the field, I want that value to be made 20 via our database.
The Input field cannot be typed in.

So how do I inject it into that code?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Show DIV if input field is >= $row->number

Post by Celauran »

JavaScript runs client side. I can manipulate any code that exists on my machine. I can, therefore, change the value of the markup, revealing the hidden box whenever I please. What you need here is additional server-side validation to protect against tampering. As for injecting it, just use a data attribute like I suggested earlier.

Code: Select all

<div class="some-wrapper" data-threshold="10">
    <input foo bar etc>
</div>
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Show DIV if input field is >= $row->number

Post by simonmlewis »

Can I simply do this?

Code: Select all

<script>
var threshold = '<?php echo $specialnumber;?>';
... <script>
I can pop that value into a variable on a query just above the code.
IT doesn't matter too much, because the Cart is run from a separate system, so even if they hacked it, it would not do it anything - it's more for just a bit of "sales patter" to say "hey... yes you have added a value that means you get a free lollipop"... lol.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Show DIV if input field is >= $row->number

Post by Celauran »

You could, though that does nothing to prevent the end user from manipulating that value.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Show DIV if input field is >= $row->number

Post by simonmlewis »

Bingo! :)
As I say, it's control "stringently" by our external cart system.
This is more just for the "flannel"... lol.

The pricing and stuff isn't actually passed over!
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply