在此特定示例中,我尝试在下拉菜单中进行选择,并在 'something'
onclick() >下面提到的处理程序,其中包含与 #panel_link_library
中所做选择相关联的任何值。希望这有道理吗?
var aaa = document.getElementById('panel_link_library')
aaa.onchange = function() {
document.getElementById("abc").href = this.value
}

<div class="dropdown-plans">
<select id="panel_link_library" name="p_links">
<option value="/pages/home_up/">Location 1</option>
<option value="www.google.com">Location 2</option>
<option value="https://321.com">Location 3</option>
</select>
</div>
<div id="abc" class="panel_link" onclick="location.href='something'">Jump to location</div>
&#13;
答案 0 :(得分:1)
您的let users = getRealmJSON(name: "Users", realmObject: Users(), realmType: Users.self)
let posts = getRealmJSON(name: "Posts", realmObject: Posts(), realmType: Posts.self)
只需要阅读选择的值!
onclick
&#13;
const navToSelection = _ => {
const el = document.getElementById("panel_link_library")
const val = el.options[el.selectedIndex].value
window.location.href = val // That's it!
}
&#13;
<div id="abc" class="panel_link" onclick="navToSelection()">Jump to location</div>
id = panel_link_library
属性答案 1 :(得分:1)
更改onclick功能的位置,然后您可以获取保管箱值并重定向用户。
希望这就是你要找的东西。如果需要,很乐意解释或帮助提供更好的解决方案。
PromptDialog.Confirm(context,confirmOption,"Are you sure?");
&#13;
Private Sub CommandButton1_Click()
Dim updRange1 As Range
Dim list As String
On Error GoTo Whoa
Set updRange1 = Application.InputBox("Please select all Tasks ID Cells you would like to update", "Update Range", Type:=8)
Application.ScreenUpdating = False
updRange1.NumberFormat = "@"
Dim matchCounter As Integer
Dim errorCounter As Integer
matchCounter = 0
errorCounter = 0
Dim FoundRange As Range
For Each updrng1 In updRange1
''tests task exists in work range 2
WorkRng2.Parent.Activate
If updrng1 <> 0 And updrng1 <> "Sub Total - Labor Fees" And updrng1 <> "Sub Total - Meetings" And updrng1 <> 21 Then
Set FoundRange = WorkRng2.Find(what:=updrng1.Value, LookIn:=xlValues, LookAt:=xlWhole)
If FoundRange Is Nothing Then
list = list & updrng1 & ", "
errorCounter = errrorCounter + 1
Else
'updates subtask info
If Me.txtSubTask.Value <> 0 Then
WorkRng2.Find(what:=updrng1.Value, LookIn:=xlValues, LookAt:=xlWhole).Select
If Cells(ActiveCell.Row, subTskRng.Column) <> 0 Then
Cells(ActiveCell.Row, subTskRng.Column).Copy
Else
Cells(ActiveCell.Row, subTskRng.Column - 1).Copy
End If
WorkRng1.Parent.Activate
updRange1.Find(what:=updrng1.Value, LookIn:=xlValues, LookAt:=xlWhole).Select
Cells(ActiveCell.Row, Me.txtSubTask.Value).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
'updates UOM info
If Me.txtUOM.Value <> 0 Then
WorkRng2.Parent.Activate
WorkRng2.Find(what:=updrng1.Value, LookIn:=xlValues, LookAt:=xlWhole).Select
Cells(ActiveCell.Row, UOMRng.Column).Copy
WorkRng1.Parent.Activate
updRange1.Find(what:=updrng1.Value, LookIn:=xlValues, LookAt:=xlWhole).Select
Cells(ActiveCell.Row, Me.txtUOM.Value).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
'updates Number of units info
If Me.txtNoUnits.Value <> 0 Then
WorkRng2.Parent.Activate
WorkRng2.Find(what:=updrng1.Value, LookIn:=xlValues, LookAt:=xlWhole).Select
Cells(ActiveCell.Row, nmbrRng.Column).Copy
WorkRng1.Parent.Activate
updRange1.Find(what:=updrng1.Value, LookIn:=xlValues, LookAt:=xlWhole).Select
Cells(ActiveCell.Row, Me.txtNoUnits.Value).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
'updates Units Cost info
If Me.txtUnitCost.Value <> 0 Then
WorkRng2.Parent.Activate
WorkRng2.Find(what:=updrng1.Value, LookIn:=xlValues, LookAt:=xlWhole).Select
Cells(ActiveCell.Row, unitCostRng.Column).Copy
WorkRng1.Parent.Activate
updRange1.Find(what:=updrng1.Value, LookIn:=xlValues, LookAt:=xlWhole).Select
Cells(ActiveCell.Row, Me.txtUnitCost.Value).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
If Me.txtBgtTotal.Value <> "" Then
Cells(ActiveCell.Row, Me.txtBgtTotal.Value).Formula = "=" & Me.txtNoUnits.Value & updrng1.Row & "*" & Me.txtUnitCost.Value & updrng1.Row
End If
matchCounter = matchCounter + 1
End If
End If
Next
updRange1.NumberFormat = "0.0"
Application.ScreenUpdating = True
If matchCounter > 0 Then MsgBox matchCounter & " Tasks Updated!", vbInformation, "Success!"
If errorCounter > 0 Then MsgBox "Mismatches: " & list, vbInformation, "Please update the following tasks manually!"
'Clear input controls
Me.txtSubTask.Value = ""
Me.txtUOM.Value = ""
Me.txtNoUnits.Value = ""
Me.txtUnitCost.Value = ""
Me.txtBgtTotal.Value = ""
txtSubTask.SetFocus
Exit Sub
Whoa:
Select Case Err.Number
Case 1004
MsgBox "Check Your Column Letters!", vbInformation, "Oops!"
End Select
End Sub
&#13;
答案 2 :(得分:0)
您正在尝试为div分配href。将它分配给onclick处理程序。
var aaa = document.getElementById('panel_link_library');
aaa.onchange = function (e) {
console.log(e);
var abc = document.getElementById("abc");
abc.addEventListener('click', () => {window.location = e.target.value});
}