首页 \ 问答 \ IE7的下拉重置问题在FireFox和Chrome上运行正常(Dropdown reset issues with IE7 works fine on FireFox and Chrome)

IE7的下拉重置问题在FireFox和Chrome上运行正常(Dropdown reset issues with IE7 works fine on FireFox and Chrome)

Hello Stackoverflow我有一个简单的表单验证逻辑,由于某种原因似乎不适用于IE7。

基本上我有两个下拉框和一个输入框。 当第一个下拉框状态更改另一个下拉列表并且输入框清除时。

目前这种逻辑似乎适用于FF,Chrome但不适用于IE7。 此外,清除输入框也可以在IE上按预期工作。

$('#names').change(function(){
    $('#rate').val("0");
    $('#amount').val("");
});

任何帮助将不胜感激。


Hello Stackoverflow I have a simple form validation logic that doesn't seem to work on IE7 for some reason.

Basically I have two dropdown boxes and an input box. When the first dropdown box state changes the other dropdown and inputbox clears.

Current this logic seem to work on FF, Chrome but not IE7. Also the clearing of the input box works as expected on IE as well.

$('#names').change(function(){
    $('#rate').val("0");
    $('#amount').val("");
});

Any helps would be greatly appreciated.


原文:https://stackoverflow.com/questions/16530266
更新时间:2022-01-06 07:01

最满意答案

危险。 strcat()strcpy()是代码癌症的主要原因。 使用它们会使您暴露于各种缓冲区溢出。 使用strncat() / strncpy() ,或者(甚至更好)只使用std::string ,因为你正在使用C ++!

strcat()strcpy()期望它们的参数是字符串。 *article[r]是一个char - article[r]是你想要的字符串。 所以,放下主要的星号。


DANGER. strcat() AND strcpy() ARE THE LEADING CAUSES OF CODE CANCER. Using them exposes you to all kinds of buffer overflows. Use strncat()/strncpy(), or (even better) just use std::string, since you're using C++!

strcat() and strcpy() expect their arguments to be strings. *article[r] is a single char--article[r] is the string you want. So, drop the leading asterisks.

相关问答

更多
  • strcpy和strcat用于将字符串复制并连接到已分配的char数组。 因为str没有被启动你在内存中编写某个地方而这很糟糕,因为你正在破坏其他数据。 它可能在那一刻工作,但迟早你的程序会崩溃。 在声明str时你应该分配内存: char str[100]; 此外, strcat效率不高,因为它需要搜索字符串end以了解连接字符的位置。 使用sprintf会更有效: sprintf(str, "\t<%s>[%s](%s) $ ", time, user, baseName); 最后,如果你不能保证生成的字 ...
  • strcpy(ptr2, ptr1)等效于while(*ptr2++ = *ptr1++) 其中strdup相当于 ptr2 = malloc(strlen(ptr1)+1); strcpy(ptr2,ptr1); ( memcpy版本可能会更有效率) 所以如果你想要复制的字符串在另一个函数中使用(因为它是在heap部分创建的),你可以使用strdup,否则strcpy就足够了。 strcpy(ptr2, ptr1) is equivalent to while(*ptr2++ = *ptr1++) wh ...
  • 当使用std :: strcpy时,我们将给定地址的值作为其第二个参数,并将此值赋给作为第一个参数(cstr)给出的指针。 char * strcpy ( char * destination, const char * source ); 没有strcpy实际读取源指向的每个字符并在目标处写入它,它在读取终止空字符时停止。 在第二个示例中,source参数是一个string-literal,其类型为const char []。 此字符串可以衰减为const char *以传递给strcpy。 字符串文字 ...
  • 危险。 strcat()和strcpy()是代码癌症的主要原因。 使用它们会使您暴露于各种缓冲区溢出。 使用strncat() / strncpy() ,或者(甚至更好)只使用std::string ,因为你正在使用C ++! strcat()和strcpy()期望它们的参数是字符串。 *article[r]是一个char - article[r]是你想要的字符串。 所以,放下主要的星号。 DANGER. strcat() AND strcpy() ARE THE LEADING CAUSES OF COD ...
  • c是单个字符,而a是一个字符串(这解释了为什么c只能容纳一个字符,以及编译器为什么抱怨)。 如果你想让c持有一个完整的字符串,那就这样声明它(就像你对sentence所做的那样)。 c is a single character, while a is a string (which explains both why c can only hold a single character, and why the compiler is complaining). If you want c to hold ...
  • 问题是你正在泄漏记忆。 对strdup的调用会分配未释放的内存。 传递给strcpy的内存指针永远不会保存在任何地方,因此编译器可以证明它已被泄漏。 我不知道你在做什么,因为strdup执行分配和复制,所以对strcpy看起来是多余的。 The problem is that you are leaking memory. The call to strdup allocates memory which is not freed. The pointer to the memory that is pas ...
  • 这两个函数都适用于char*类型。 当您在定义的某个常量字符串上使用strcpy时,此字符串位于代码空间中,这可能是一个问题,因此警告。 导致第二个错误是因为您无法将整数连接到字符串。 当你想要打印这个短的值时,你需要将它转换为例如通过sprintf转换为char*而不是连接这个char* 。 Both functions work on char* types. When you use strcpy on some constant string you defined, this string is ...
  • 通过做a = malloc(2*sizeof(char)); 在函数void doSth(char *a) ,a的本地副本在函数范围内被修改,但不在其中。 如果你想修改myString ,应该给函数一个指向myString ( &myString )的指针。 它被称为传递指针: char *myString; doSth(&myString); 该函数的原型相应地改变: void doSth(char **a){ ... *a = malloc(2*sizeof(char)); strcpy ...
  • 尝试 memcpy(tmp, &(SB->jNodes[j]), sizeof(SB->jNodes[0])); 因为你不是在复制字符串而不是strcpy。 Try memcpy(tmp, &(SB->jNodes[j]), sizeof(SB->jNodes[0])); Not strcpy since you're not copying strings.
  • 你需要在复制前检查空指针。 token = strtok(line, s); strcpy(update, token); token = strtok(NULL, s); //token = token + '\0'; if(NULL != token) { strcpy(firstName, token); token = strtok(NULL, s); } you need check null pointer before copy. token = strtok(line, s ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)