Do you have such a situation?
When you use jquery to obtain the ddl value of the drop-down list, the returned string is 'null' instead of a null value. As a result, the obtained parameter is incorrect;
Even if it is determined in the background that it is not empty, it still leads to an error (for example, the null is spelled in when the SQL statement is pieced together ).
The following is an analysis:
First case:
Copy codeThe Code is as follows:
<Select id = "ddlType">
<Option value = ""> select </option>
<Option value = "1"> Anhui </option>
......
</Select>
Case 2:
Copy codeThe Code is as follows:
<Select id = "ddlType"> </select>
Or
<Asp: DropDownList ID = "ddlType" runat = "server"> </asp: DropDownList>
The values in the program are as follows:
$ ("# DdlType"). val ()
In the first case, if we do not make a selection, then it returns the null value "", but not the string "null ";
In the second case, there is no option in ddl, And the foreground is not written to death or the background is not bound. If you retrieve the value, the return string "null" is returned ".
Solution: currently, no better solution is found. You can only add a judgment in the background (! = "Null"). Obviously, this is not a good solution.
Another method provided by friends on the Internet is to modify the jquery source file and change this. value = val in the last sentence of the val function to this. value = val | "";
If you have any good ideas, please share them with us !!!