Forum Discussion

aakash22's avatar
aakash22
Occasional Contributor
10 years ago

How to pass variable to eval(JavaScript) function

i have been trying to pass date value to my uneditable date filed.

so i have retrieved the javascript ID(startDateCalendar_dateTextBox) for the field and i am trying to pass multiple values to the same.

 

 contentDocument.Script.eval("var tr = document.getElementById('startDateCalendar_dateTextBox'); tr.value='swap';");

 

So, the problem here is passing multiple values to this field. i want to data drive this.

  • Is there a specific reason you're using eval? Can't you access the object directly like this?

    var obj = page.FindChildByXPath("//*[@id='startDateCalendar_dateTextBox']");
    
    // Or narrow down the search by specifying the HTML tag, for example: // var obj = page.FindChildByXPath("//input[@id='startDateCalendar_dateTextBox']");
    obj.value = ...;

     

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Is there a specific reason you're using eval? Can't you access the object directly like this?

    var obj = page.FindChildByXPath("//*[@id='startDateCalendar_dateTextBox']");
    
    // Or narrow down the search by specifying the HTML tag, for example: // var obj = page.FindChildByXPath("//input[@id='startDateCalendar_dateTextBox']");
    obj.value = ...;