显示输入的初始值

时间:2017-02-21 18:20:32

标签: javascript html html5

我有一个输入字段,我想要显示一些默认值或初始值。之后,每当用户更改值时,它应该更改,但初始值应该是我给出的值。但我无法做到这一点。这是我的输入

Public Class Class1

     Private Parent_From as Form1
     Public Sub New(Parent as Form1)
           Parent_From = Form
     End sub
     Public Sub count()
        Dim i As Integer
        For i = 0 To 100
            ' this method will be executed by thread "myThread"
            Parent_Form.addTExt("Whatever")
            Debug.WriteLine("Index: {0}", i)
        Next
    End Sub
End CLass

我也尝试了<input placeholder={this.props.edit_tag_reducer.time_in} id="time_in" type="text" value={this.secondsToHms(this.props.new_marker_reducer.start)} /> ,但没有成功。

2 个答案:

答案 0 :(得分:0)

您需要附上引号:

CT-Driver Automation Suite Iteration Message: Failed: No element found using locator: By(xpath, //div[@wj-part='root']//div[@wj-part='cells']//div[4]//span) Stack: NoSuchElementError: No element found using locator: By(xpath, //div[@wj-part='root']//div[@wj-part='cells']//div[4]//span) at WebDriverError (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:10) at NoSuchElementError (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:242:10) at c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\built\element.js:699:27 at ManagedPromise.invokeCallback_ (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14) at TaskQueue.execute_ (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14) at TaskQueue.executeNext_ (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21) at c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2775:27 at c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7 at process._tickCallback (node.js:369:9) From: Task: WebDriver.executeScript() at Driver.schedule (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:377:17) at Driver.executeScript (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:526:16) at Browser.to.(anonymous function) [as executeScript] (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\built\browser.js:60:29) at Object.highlightElement (c:\Users\*\Documents\projects\*\ct-driver\common\commonHelper.js:409:24) at c:\Users\*\Documents\projects\*\ct-driver\services\seleniumService.js:82:34 at ManagedPromise.invokeCallback_ (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14) at TaskQueue.execute_ (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14) at TaskQueue.executeNext_ (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21) at c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2775:27 at c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7 From: Task: Run it("Suite Iteration") in control flow at Object.<anonymous> (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\jasminewd2\index.js:81:14) at c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\jasminewd2\index.js:18:5 at ManagedPromise.invokeCallback_ (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14) at TaskQueue.execute_ (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14) at TaskQueue.executeNext_ (c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21) at c:\Users\*\Documents\projects\*\ct-driver\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2775:27 From asynchronous test: Error at Suite.<anonymous> (c:\Users\*\Documents\projects\*\ct-driver\app.js:111:3) at Object.<anonymous> (c:\Users\*\Documents\projects\*\ct-driver\app.js:65:1) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12)

这将作为默认(初始)值。 (没有defaultValue属性。)

如果这没有显示值,那是因为您的属性不正确或者它没有转换为Hms。

您可以尝试`value =“1:10:35”来测试问题所在

鉴于您的问题不明确,您可能希望让占位符标记正常工作。

同样适用。用引号括起来:

value='"' + {this.secondsToHms(this.props.new_marker_reducer.start)} + '"'

答案 1 :(得分:0)

在输入框中同时包含placeholdervalue属性是没有意义的,因为占位符用于最初缺少值或完全丢失的值,但是因为你正在设置它,你不会需要它我不会想。

另外请记住,此处列出的value属性仅影响DOM,它实际上并不是JS中该输入的值。

并确保{this.props...}实际上包含您想要的值。