Попытка открыть созданный файл блокнота (созданный из моей функции submitOrder) с помощью функции "OpenFile", но я не могу заставить его работать.Помогите, пожалуйста, получить ошибку «система не может найти указанный файл», как мне изменить мою функцию «openFile», чтобы открыть созданный файл.
КОД JAVASCRIPT:
function submitOrder(file)
{
var fso = new ActiveXObject ("scripting.filesystemobject")
var newfile = fso.createTextFile (file,true);
var string = "";
var orderlist = document.getElementById("orderlist");
for (i=0; i < orderlist.length; i++)
{
if ( orderlist.options[i].text != "list of ordered items" )
{
string = string + orderlist.options[i].text + '\r\n';
}
}
newfile.WriteLine(string);
newfile.Close();
alert('Your order has been submitted to the text file ' + file);
}
function OpenFile(file)
{
wshell = new ActiveXObject("WScript.Shell");
wshell.run("Z:\Local\eric.mahinay\Assignment 4 Programming" + file ,1,false);
}
СЛЕДУЮЩИЙ КОД HTML:
<body onload="screen();">
<h1>Gigantuano Pizza Company</h1>
<p>Place your order now!</p>
<select id="pizza" >
<option value="0.00">Select a pizza</option>
<option value="10.00">Hawaiian - Large Stuffed Crust - $10.00</option>
<option value="8.00">Hawaiian - XL Standard Base - $8.00</option>
<option value="13.50">Hawaiian - XL Stuffed Crust - $13.50</option>
<option value="10.00">Beef and Onion - Large Stuffed Crust -
$10.00</option>
<option value="8.00">Beef and Onion - XL Standard Base - $8.00</option>
<option value="13.50">Beef and Onion - XL Stuffed Crust - $13.50</option>
<option value="11.00">Peperoni Lovers - Large Stuffed Crust -
$11.00</option>
<option value="13.50">Chicken Supreme - Large Stuffed Crust -
$13.50</option>
</select>
<input type ="button" onclick="addOrderItem()" value="Add Order Item"><br>
<br>
Ordered Items: click to check order
<select id="orderlist"><option value="0.00">list of ordered items</option>
</select>
<input type ="button" onclick="removeOrderItem();" value="Remove Order
Item">
<br>
Order Total: <input type ="text" id="ordertotal" value=0.0></input><br>
<br>
<br>
Type your order submission file name (one word):<input type ="text"
id="orderfilename" value=""></input>
Click to submit your order:
<input type ="button"
onclick="submitOrder(document.getElementById('orderfilename').value +
'.txt');" value="Submit Order">
<input type="button" value="Open Order Text File" onclick="OpenFile(
document.getElementById('orderfilename').value + '.txt' );"/>
<br>
</body>
</html>