我在 Chrome 扩展程序上工作,我需要根据从 CSV 读取的数字更新使用 React 制作的 html 页面的大量输入。我无法更新网站。
- 从渲染网站复制的输入示例:
<td><input class="input input_small fpInput" value="29,4"></td>
Run Code Online (Sandbox Code Playgroud)
- 它是如何制作的(不确定 100%,必须阅读丑陋的 js 源代码)
{
key: "render",
value: function () {
return s.a.createElement("input", {
className: "input input_small fpInput",
value: this.state.value,
onChange: this.handleChange,
onBlur: this.handleSubmit,
onFocus: this.handleFocus
})
}
}
Run Code Online (Sandbox Code Playgroud)
- 每次更改输入值时,都会调用一个函数并进行 POST 以保存它。
我想在更改输入值以触发 POST 后从我的扩展中触发onBlur()或onChange()
我试过这个:
var el = document. ... .querySelector('input'); // the selector is simplied of course
el.value = 321;
el.onChange(); // ERROR onChange is not a …Run Code Online (Sandbox Code Playgroud) 我有一个隐藏输入的表单.
我.clone()它们并在.dialog()中向用户显示它们.
用户进行了一些更改,我使用.val()来更改隐藏的字段.
然而,下次我克隆表单(没有重新加载页面)我再次有初始值,而不是更新的.
似乎有这个奇怪的错误/结果?请参阅http://jsfiddle.net/YvBfP/ (因可见输入而损坏)
$(this).closest('td').find('button').click( function ()
{
var d = $('#pagamento_anticipato').html();
$(d).dialog({
modal: true,
width: 400,
height: 300,
close: function( event, ui ) {
var importo = $(this).find('input[type="text"]').val();
var descrizione = $(this).find('textarea').val();
var select = $(this).find('select').val();
$(this).remove();
$('#pagamento_anticipato').find('input[id="importo"]').val( importo );
$('#pagamento_anticipato').find('#descrizione').val( descrizione );
$('#pagamento_anticipato').find('#tipo').find('option[value="' + select + '"]').attr('selected', true);
}
});
return false;
});
Run Code Online (Sandbox Code Playgroud) 我想做这样的事情,但出现“分配中的左侧无效”错误。
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "http://example.com/example.js";
s.data-flix-distributor = "12994";
Run Code Online (Sandbox Code Playgroud) OOPS,因为"名称"字段位于顶部,所以我正在测试它,结果发现这是唯一一个有问题的字段.必须与使用"名称"作为名称有关...
由于某种原因,我的表单中的输入标记在更改时不会更新value属性查看实际元素(而不是JavaScript).发布到服务器的数据是"value"属性的原始值,而不是文本框中的文本.
表单中的textareas工作正常,我已经检查了javascript解雇"onchange",我找不到任何...请帮助!
这是HTML:
<form action="" method="post">
<div id="group-1" class="group case">
<a class="heading open">heading</a>
<input name="editform[0][class]" value="case" type="hidden">
<input name="editform[0][id]" value="2" type="hidden">
<div class="field">
<label>Name</label>
<input class="text" name="editform[0][name]" value="Mike Escarcaga" type="text" >
</div>
<div class="field">
<label>Title</label>
<input class="text" name="editform[0][title]" value="General Manager" type="text" >
</div>
<!-- repeated for each field -->
<div class="field" >
<label >Text</label>
<textarea class="ltext" name="editform[0][text]" >
Blah HTML, and more blah...
</textarea>
</div>
</div>
<!-- repeated for each group in the form (editform[1], editform[2], etc.) --> …Run Code Online (Sandbox Code Playgroud) 尝试在不使用 v-model 的情况下创建复选框
<input type="checkbox" :value="value" @change="$emit('input', $event.target.checked)" />
Run Code Online (Sandbox Code Playgroud)
复选框将选中和取消选中,并将输入事件发送到父级,但值不会改变。我的父组件如下所示:
<custom-component v-model="some_boolean_value"></custom-component>
Run Code Online (Sandbox Code Playgroud) 所以我在这个 stackblitz 示例中有一个代码。
基本上有一个简单的表单,带有一个输入和一个按钮。按下按钮会将输入的当前值复制到标签:
点击后:
html:
<input id="inputID" [(ngModel)]="inputValue" />
<button id="buttonID" (click)="set()">send</button>
<hr/>
<label> new Value: {{labelValue}} </label>
<hr/>
Run Code Online (Sandbox Code Playgroud)
JS:
labelValue = "";
inputValue = "defaultValue";
set(){
this.labelValue = JSON.parse(JSON.stringify(this.inputValue));
}
Run Code Online (Sandbox Code Playgroud)
我必须仅使用本机 JS 代码来模拟用户交互。 所以我尝试以下操作(例如在浏览器控制台中):
- document.getElementById('inputID').value = "aNewValue";
- document.getElementById('buttonID').click();
Run Code Online (Sandbox Code Playgroud)
问题是这样的:
我在标签中获得了默认值,而不是当前值。我怎样才能获得正确的价值?我怀疑它与反射属性有关,但无法弄清楚这里可能是什么问题。
更新:我尝试了以下方法,但也没有运气。
element = document.getElementById('inputID')
element.value = "aNewValue";
var ev = new Event('change', {
view: window,
bubbles: true,
cancelable: true,
});
element.dispatchEvent(ev);
document.getElementById('buttonID').click();
Run Code Online (Sandbox Code Playgroud) 我正在使用机器人框架和Selenium2Library库为Web应用程序编写回归测试.我有一个简单的测试,它改变了"帐户设置"类型表单的所有字段(想想用户名,密码,电子邮件等),然后重新访问页面并确保保存了所有数据.像这样:
*** Test Cases ***
Sample Test
Change All Account Details
New Account Details Should Be Saved
*** Keywords ***
Change All Account Details
Navigate to Account Page
Input Text accountSettingFrom_firstname Test
Input Text accountSettingFrom_lastname Dummy
Input Text accountSettingFrom_email new_email@example.com
# etc etc, eventually save the form
New Account Details Should Be Saved
Go To ${ACCOUNT_URL}
Textfield Value Should Be accountSettingFrom_firstname Test
Textfield Value Should Be accountSettingFrom_lastname Dummy
Textfield Value Should Be accountSettingFrom_email new_email@example.com
Run Code Online (Sandbox Code Playgroud)
Textfield Value Should Be accountSettingFrom_email new_email@example.com …
即使是第二台收音机也检查了它没有检查,并检查最后一台
<div>
<input type="radio" id="bed_room_1" name="room[bed_room]" value="1" checked="false" />
<label for="bed_room_1">1</label>
</input>
<input type="radio" id="bed_room_2" name="room[bed_room]" value="2" checked="true" />
<label for="bed_room_2">2</label>
</input>
<input type="radio" id="bed_room_3" name="room[bed_room]" value="3" checked="false" />
<label for="bed_room_3">3</label>
</input>
<input type="radio" id="bed_room_4" name="room[bed_room]" value="4" checked="false" />
<label for="bed_room_4">4+</label>
</input>
</div>
Run Code Online (Sandbox Code Playgroud)
Codepen链接codepen