I have two files that i am trying to work with they are both cshtml files with javascript. On of the files has a checkbox that I am trying to effect with javascript. Is it possible to set a checkbox to "checked" if you are using javascript in a separate file? or say check the results of an if statement from a different file so that I can set it to "checked"?
I have a script in File2 that is running to check if there is an ID to load a tab by default. When that runs, I would like to use it to set the checkbox in File1 to "checked". Is this at all possible?
File1:
<script>
var defaultID = 0;
if (window.defaultUserID != null)
defaultID = window.defaultUserID;
</script>
<div> . . .
<label class="checkbox inline"><input type="checkbox" id="showVoidedInfo" data-bind="checked: ShowVoids" /> Show Voids</label>
. . . </div>
File2:
@{
bool loadUsersTabByDefault = false;
if (ViewBag.LinkableId != null && ViewBag.LinkableId == 1)
{
loadUsersTabByDefault = true;
}
}
<script type="text/javascript">
if (window.loadUsers !=null && window.loadUsers == true){
window.loadUsersTabByDefault = true;
window.defaultUserID = window.UserID;
document.getElementById("showVoidedInfo").checked = true;
}
else
window.loadUsersTabByDefault = false;
</script>
<div> . . . </div>
Aucun commentaire:
Enregistrer un commentaire