Forum Moderators: open
In the first file (where you have the select list), put the following code:
<script language="JavaScript" type="text/javascript"> <form name="MyForm">
function ShowEdit() {
if(document.all) {
document.MyForm.Edit.style.visibility="visible";
}
else {
document.MyForm.Edit.visibility="visible";
}
}
function EditList() {
TheValue = document.MyForm.TheList.options[document.MyForm.TheList.selectedIndex].value;
TheText = document.MyForm.TheList.options[document.MyForm.TheList.selectedIndex].text;
TheIndex = document.MyForm.TheList.selectedIndex;
window.open("edit.html?" + TheValue + "&" + TheText + "&" + TheIndex,
"EditWin",
"dependent=yes, directories=no, height=100, hotkeys=no, location=no, menubar=no, personalbar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no, width=450");
}
</script>
Select from the list: <select name="TheList" onchange="ShowEdit()">
<option value=""></option>
<option value="Test1">Test1</option>
<option value="Test2">Test2</option>
<option value="Test3">Test3</option>
<option value="Test4">Test4</option>
</select>
<input type="Button" id="Edit" name="Edit" value="Edit" style="visibility:hidden;" onclick="EditList();">
</form>
In the pop-up document (edit.html), put the following code:
<form name="MyForm"> <script language="JavaScript" type="text/javascript">
<input type="Text" name="NewValue" onkeyup="UpdateList()">
<input type="Button" id="Reset" name="Reset" value="Reset" onclick="ResetValues();">
<input type="Button" value="Close window" onclick="self.close()">
</form>
if(document.all) {
window.opener.document.MyForm.Edit.style.visibility="hidden";
}
else {
window.opener.document.MyForm.Edit.visibility="hidden";
}
QueryString = location.search.substring(1);
values = QueryString.split(/&/);
TheValue = values[0];
TheText = values[1];
TheIndex = values[2];
document.MyForm.NewValue.value = TheText;
function UpdateList() {
ChangedValue = document.MyForm.NewValue.value;
window.opener.document.MyForm.TheList.options[TheIndex].value = ChangedValue;
window.opener.document.MyForm.TheList.options[TheIndex].text = ChangedValue;
}
function ResetValues() {
window.opener.document.MyForm.TheList.options[TheIndex].value = TheValue;
window.opener.document.MyForm.TheList.options[TheIndex].text = TheText;
document.MyForm.NewValue.value = TheText;
}
</script>
But can you make it so it does not pop up in a new window? I need it to be on the same page. I apprecaite your help.
<form name="MyForm">
Select from the list:<br>
<select name="TheList" onchange="ShowEdit()">
<option value=""></option>
<option value="Test1">Test1</option>
<option value="Test2">Test2</option>
<option value="Test3">Test3</option>
<option value="Test4">Test4</option>
</select>
<input type="Button" id="Edit" name="Edit" value="Edit" style="visibility:hidden;" onclick="EditList();"><br>
<input type="Text" name="NewValue" style="visibility:hidden;" onkeyup="UpdateList()">
<input type="Button" id="Done" name="Done" value="Done" style="visibility:hidden;" onclick="DoneEditing()">
<input type="Button" id="Reset" name="Reset" value="Reset" style="visibility:hidden;" onclick="ResetValues();">
</form>
Is it possible to modify this so all the text fields and edit buttons are displayed at once and not just when you select on option from the dropdown menu?
Thanks again.
But, here's another version:
<script language="JavaScript" type="text/javascript"> <form name="MyForm">
function EditList() {
TheIndex = document.MyForm.TheList.selectedIndex;
TheValue = document.MyForm.TheList.options[TheIndex].value;
TheText = document.MyForm.TheList.options[TheIndex].text;
document.MyForm.NewValue.value = TheValue;
}
function UpdateList() {
ChangedValue = document.MyForm.NewValue.value;
document.MyForm.TheList.options[TheIndex].value = ChangedValue;
document.MyForm.TheList.options[TheIndex].text = ChangedValue;
}
function ResetValues() {
document.MyForm.TheList.options[TheIndex].value = TheValue;
document.MyForm.TheList.options[TheIndex].text = TheText;
document.MyForm.NewValue.value = TheText;
}
</script>
Select from the list:<br>
<select name="TheList" onchange="EditList()">
<option value=""></option>
<option value="Test1">Test1</option>
<option value="Test2">Test2</option>
<option value="Test3">Test3</option>
<option value="Test4">Test4</option>
</select><br>
<input type="Text" name="NewValue" onkeyup="UpdateList()">
<input type="Button" id="Reset" name="Reset" value="Reset" onclick="ResetValues();">
</form>
Can you add the edit button in there so that when you click it it will send the highlighted field to the input area to be changed.
Thanks
Thanks.