Who else will make these two mistakes ????

Source: Internet
Author: User
Who else will make these two mistakes ???? First JS issue
《script》$$=function(id){return document.getElementById(id);}var error='';if($$("bid").value.replace(/^\s+/,"").replace(/\s+$/,"")<$$("reserve_price").value){error+="Your bid must be equal to or higher than the reserve price\n";}alert($$("bid").value.replace(/^\s+/,"").replace(/\s+$/,""));alert($$("reserve_price").value);alert(error);《script》


Do you think this is correct? Run the program to see if it is correct ..

The second database problem.
Data table name product
Id int (4)
Name varchar (20 );
Price text

There are 2 records
Id name price
1 TV 750.00
2. air conditioner 5000

Sort by price
Write SQL statements
Select * from product order by price desc

If you think it is correct, run the following command,


Reply to discussion (solution)

I have been paying close attention to the landlord.

First, I will not store the price field in text, so this error will not occur.

I have been paying close attention to the landlord. Follow me

First JS issue

《script》$$=function(id){return document.getElementById(id);}var error='';if($$("bid").value.replace(/^\s+/,"").replace(/\s+$/,"")<$$("reserve_price").value){error+="Your bid must be equal to or higher than the reserve price\n";}alert($$("bid").value.replace(/^\s+/,"").replace(/\s+$/,""));alert($$("reserve_price").value);alert(error);《script》


Do you think this is correct? Run the program to see if it is correct ..

The second database problem.
Data table name product
Id int (4)
Name varchar (20 );
Price text

There are 2 records
Id name price
1 TV 750.00
2. air conditioner 5000

Sort by price
Write SQL statements
Select * from product order by price desc

If you think it is correct, run the following command,

First, it is clear that the price must be replaced by regular expressions, and the habit of making a price comparison is to convert it into a digital comparison.
I don't think "who will make these two mistakes", but "who will write this code ".

The first one is entered in the text box,
For example, I can enter 5000 with so many spaces.

The second price is fixed.


First JS issue

《script》$$=function(id){return document.getElementById(id);}var error='';if($$("bid").value.replace(/^\s+/,"").replace(/\s+$/,"")<$$("reserve_price").value){error+="Your bid must be equal to or higher than the reserve price\n";}alert($$("bid").value.replace(/^\s+/,"").replace(/\s+$/,""));alert($$("reserve_price").value);alert(error);《script》


Do you think this is correct? Run the program to see if it is correct ..

The second database problem.
Data table name product
Id int (4)
Name varchar (20 );
Price text

There are 2 records
Id name price
1 TV 750.00
2. air conditioner 5000

Sort by price
Write SQL statements
Select * from product order by price desc

If you think it is correct, run the following command,

First, it is clear that the price must be replaced by regular expressions, and the habit of making a price comparison is to convert it into a digital comparison.
I don't think "who will make these two mistakes", but "who will write this code ".

If ($ ("bid "). value. replace (/^ \ s + /,""). replace (/\ s + $/, "") <$ ("reserve_price "). value)
Should be
If (parseFloat ($ ("bid"). value)
Select * from product order by price desc
Should be
Select * from product order by price + 0 desc
Or change the price to the DECIMAL type.

Again, replace (/^ \ s +/, ""). replace (/\ s + $/, "") is too weird.
. Replace (/^ \ s + | \ s + $/g ,"")

Again, replace (/^ \ s +/, ""). replace (/\ s + $/, "") is too weird.
. Replace (/^ \ s + | \ s + $/g ,"")
I used to search for regular expressions on the Internet.

First, I will not store the price field in text, so this error will not occur.
This error is caused by the use of some cms systems and the creation of data fields in the background. the default value is text, so ......


I have been paying close attention to the landlord. Follow me
Your: YouYaX Open Source Forum



I have been paying close attention to the landlord. Follow me
Your: YouYaX Open Source Forum
Why is csdn revised? I suddenly felt that the reference effect of csdn was a little imitating my design,
This was not the case before.

Haha,

It is impossible to make such a mistake. How can price be text?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.