Jump to content
  • 0

Сохронение выброного значения select.


n1cks0n
 Share

Question

Всем привет, помогите пожалуйста с сохранением выбранного значения select, это гаджет для windows.

Т.е. до select был текстовое поле и server1NameField.innerText = System.Gadget.Settings.read("savedServer1Name"); сохранял текст, когда поменял поле text на select, после сохранения с тегом innerText почему-то пропадает выбор select. Помогите разобраться:)

Код:

<html>
<html>
<head>
<style>body{width: 250px; height: 350px; font-family: Tahoma; font-size: 10px;}p{top-margin: .5em;}</style>
<script>

var serverType = new Array(["Counter-Strike", "-a2s "]);


System.Gadget.onSettingsClosing = settingsClosing;
function loadSettings(){

for(var i=0;i<serverType.length;i++){
server1.options[i]=new Option(serverType[i][0], serverType[i][1]);
server1.options[i].title=serverType[i][0];}
for(var i=0;i<serverType.length;i++){
server2.options[i]=new Option(serverType[i][0], serverType[i][1]);
server2.options[i].title=serverType[i][0];}
for(var i=0;i<serverType.length;i++){
server3.options[i]=new Option(serverType[i][0], serverType[i][1]);
server3.options[i].title=serverType[i][0];}

if (System.Gadget.Settings.read("SettingsExist")){
server1NameField.inner = System.Gadget.Settings.read("savedServer1Name");
server1PortField.innerText = System.Gadget.Settings.read("savedServer1Port");
with (server1){
value = System.Gadget.Settings.read("savedServer0Type");}
server1DisplayName.innerText = System.Gadget.Settings.read("savedServer0DisplayName");

server2NameField.inner = System.Gadget.Settings.read("savedServer2Name");
server2PortField.innerText = System.Gadget.Settings.read("savedServer2Port");
with (server2){
value = System.Gadget.Settings.read("savedServer3Type");}
server2DisplayName.innerText = System.Gadget.Settings.read("savedServer3DisplayName");

server3NameField.inner = System.Gadget.Settings.read("savedServer3Name");
server3PortField.innerText = System.Gadget.Settings.read("savedServer3Port");
with (server3){
value = System.Gadget.Settings.read("savedServer6Type");}
server3DisplayName.innerText = System.Gadget.Settings.read("savedServer6DisplayName");
}
}


function settingsClosing(event)
{
if (event.closeAction == event.Action.commit)
{
WriteFirstLnBat(server1NameField.value, server1PortField.value, server1.value.substr(0,6));
System.Gadget.Settings.write("savedServer1Name", server1NameField.value);
System.Gadget.Settings.write("savedServer1Port", server1PortField.value);
System.Gadget.Settings.write("savedServer0Type", server1.value);
System.Gadget.Settings.write("savedServer0DisplayName", server1DisplayName.value);

if ( server2NameField.value != "" )
WriteRestBat(server2NameField.value, server2PortField.value, server2.value.substr(0,6));
System.Gadget.Settings.write("savedServer2Name", server2NameField.value);
System.Gadget.Settings.write("savedServer2Port", server2PortField.value);
System.Gadget.Settings.write("savedServer3Type", server2.value);
System.Gadget.Settings.write("savedServer3DisplayName", server2DisplayName.value);

if ( server3NameField.value != "" )
WriteRestBat(server3NameField.value, server3PortField.value, server3.value.substr(0,6));
System.Gadget.Settings.write("savedServer3Name", server3NameField.value);
System.Gadget.Settings.write("savedServer3Port", server3PortField.value);
System.Gadget.Settings.write("savedServer6Type", server3.value);
System.Gadget.Settings.write("savedServer6DisplayName", server3DisplayName.value);


System.Gadget.Settings.write("SettingsExist", true);
}
}
</script>

<script language="VBScript" type="text/VBScript">

Function WriteFirstLnBat(server1,port1,stype1)
Set objFSO = CreateObject("Scripting.FileSystemObject")
strPath = System.Gadget.path & "\en-US\"
Set ta=objFSO.OpenTextFile(strPath & "qstat.bat" ,2)
ta.WriteLine("""" & strPath & "qstat.exe"" -noconsole -Ts """ & strPath & "cssource.tmp"" " & stype1 & " " & server1 & " > """ & strPath & "qstat.txt""")
ta.Close
End Function

Function WriteRestBat(server2,port2,stype2)
Set objFSO = CreateObject("Scripting.FileSystemObject")
strPath = System.Gadget.path & "\en-US\"
Set ta=objFSO.OpenTextFile(strPath & "qstat.bat" ,8)
ta.WriteLine("""" & strPath & "qstat.exe"" -noconsole -Ts """ & strPath & "cssource.tmp"" " & stype2 & " " & server2 & " >> """ & strPath & "qstat.txt""")
ta.Close
End Function
</script>

</head>

<body onload="loadSettings()">
<label for="server1NameField"><b>Сервер №1:</b><br>Сервер:</label><br />
<select name="server1NameField" id="server1NameField" size="1" />
<option selected value=""></option>
<option value="212.16.194.69:27016">Classic CS:S</option>
<option value="212.16.194.69:27015">Meat CS:S</option>
<option value="212.16.218.170:27016">SKH CS:S</option>
<option value="212.16.194.69:27017">Mix CS:S</option>
<option value="212.16.194.69:27018">Mix2 CS:S</option>
<option value="212.16.218.170:27018">SKH Mix CS:S</option>
<option value="80.243.68.74:27016">Neo-Sfera CS:S</option>
<option value="80.243.68.74:27018">Neo-Sfera Mix CS:S</option>
<option value="212.16.194.66:27022">Classic CS1.6</option>
<option value="212.16.194.66:27015">Meat CS1.6</option>
<option value="212.16.218.170:27015">SKH CS1.6</option>
<option value="212.16.194.66:27019">Mix CS1.6</option>
<option value="212.16.194.66:27021">Mix2 CS1.6</option>
<option value="212.16.218.170:27017">SKH Mix CS1.6</option>
<option value="212.16.194.66:27016">DM CS1.6</option>
<option value="212.16.194.66:27017">Aim CS1.6</option>
<option value="80.243.68.74:27015">Neo-Sfera CS1.6</option>
<option value="80.243.68.74:27017">Neo-Sfera Mix CS1.6</option>
</select>
<label for="server1PortField"></label>
<br /><input type="text" name="server1PortField" id="server1PortField" style="position:absolute;left:-2001px;width:2001px" size=1 />
<select id="server1" style="position:absolute;left:-2001px;width:2001px""width:150px;font-size:12px;"></select>
<label for="server1DisplayName">Имя Сервера(Опционально):</label>
<input type="text" name="server1DisplayName" id="server1DisplayName" size=9 length="20" />
<br /> <label for="server2NameField"><b>Сервер №2:</b><br>Сервер:</label><br />
<select name="server2NameField" id="server2NameField" size="1" />
<option selected value=""></option>
<option value="212.16.194.69:27016">Classic CS:S</option>
<option value="212.16.194.69:27015">Meat CS:S</option>
<option value="212.16.218.170:27016">SKH CS:S</option>
<option value="212.16.194.69:27017">Mix CS:S</option>
<option value="212.16.194.69:27018">Mix2 CS:S</option>
<option value="212.16.218.170:27018">SKH Mix CS:S</option>
<option value="80.243.68.74:27016">Neo-Sfera CS:S</option>
<option value="80.243.68.74:27018">Neo-Sfera Mix CS:S</option>
<option value="212.16.194.66:27022">Classic CS1.6</option>
<option value="212.16.194.66:27015">Meat CS1.6</option>
<option value="212.16.218.170:27015">SKH CS1.6</option>
<option value="212.16.194.66:27019">Mix CS1.6</option>
<option value="212.16.194.66:27021">Mix2 CS1.6</option>
<option value="212.16.218.170:27017">SKH Mix CS1.6</option>
<option value="212.16.194.66:27016">DM CS1.6</option>
<option value="212.16.194.66:27017">Aim CS1.6</option>
<option value="80.243.68.74:27015">Neo-Sfera CS1.6</option>
<option value="80.243.68.74:27017">Neo-Sfera Mix CS1.6</option>
</select>
<label for="server2PortField"></label>
<input type="text" name="server2PortField" id="server2PortField" style="position:absolute;left:-2001px;width:2001px" size=4 length="6" />
<br /><select id="server2" style="position:absolute;left:-2001px;width:2001px""width:150px;font-size:12px;"></select>
<label for="server2DisplayName">Имя Сервера(Опционально):</label>
<input type="text" name="server2DisplayName" id="server2DisplayName" size=9 length="20" />
<br /> <label for="server3NameField"><b>Сервер №3:</b><br>Сервер:</label><br />
<select name="server3NameField" id="server3NameField" size="1" />
<option selected value=""></option>
<option value="212.16.194.69:27016">Classic CS:S</option>
<option value="212.16.194.69:27015">Meat CS:S</option>
<option value="212.16.218.170:27016">SKH CS:S</option>
<option value="212.16.194.69:27017">Mix CS:S</option>
<option value="212.16.194.69:27018">Mix2 CS:S</option>
<option value="212.16.218.170:27018">SKH Mix CS:S</option>
<option value="80.243.68.74:27016">Neo-Sfera CS:S</option>
<option value="80.243.68.74:27018">Neo-Sfera Mix CS:S</option>
<option value="212.16.194.66:27022">Classic CS1.6</option>
<option value="212.16.194.66:27015">Meat CS1.6</option>
<option value="212.16.218.170:27015">SKH CS1.6</option>
<option value="212.16.194.66:27019">Mix CS1.6</option>
<option value="212.16.194.66:27021">Mix2 CS1.6</option>
<option value="212.16.218.170:27017">SKH Mix CS1.6</option>
<option value="212.16.194.66:27016">DM CS1.6</option>
<option value="212.16.194.66:27017">Aim CS1.6</option>
<option value="80.243.68.74:27015">Neo-Sfera CS1.6</option>
<option value="80.243.68.74:27017">Neo-Sfera Mix CS1.6</option>
</select>
<label for="server3PortField"></label>
<input type="text" name="server3PortField" id="server3PortField" style="position:absolute;left:-2001px;width:2001px" size=1 length="1" />
<br /><select id="server3" style="position:absolute;left:-2001px;width:2001px""width:150px;font-size:12px;" "unvisible"></select>
<label for="server3DisplayName">Имя Сервера(Опционально):</label>
<input type="text" name="server3DisplayName" id="server3DisplayName" size=9 length="20" />
<br /><b>Пинг</b>:
                                  <a href= ".\pingon.exe"><img src= ".\images\on.png"></a>   <a href= ".\pingoff.exe"><img src= ".\images\off.png"> </a>
<p>
</body>
</html>

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy