sherbug1015
asked on
Passing Parameters to a JQuery Script
I have a task to show/hide two objects on my webform based on two dates. This is what I have so far:
<%@ Page Language="C#" AutoEventWireup="false" CodeFile="Default2.aspx.cs " Inherits="Default2" %>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script>
$(function(){
var current = new Date();
var pollstartdate = new Date("April 1, 2015 13:00")
var pollenddate = new Date("April 30, 2015 15:00")
if(current.getTime()>=poll startdate. getTime() && current.getTime()<=pollend date.getTi me()){
$('#pollvote').show();
$('#pollcommentbox').hide( );
}
else if(current.getTime()>=poll enddate.ge tTime()){
$('#pollcommentbox').show( );
$('#pollvote').hide();
}
});
$('#pollvote').show();
</script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="pollvote" style="display:none">
<p>This is where the user will vote #pollvote</p>
</div>
<div id="pollcommentbox" style="display:none">
<p>This is where the user will leave a comment #pollcommentbox</p>
</div>
</form>
</body>
</html>
Right now I have the two dates that I need hard coded, but I will be getting them off another form. How do I pass these parameters into my script?
<%@ Page Language="C#" AutoEventWireup="false" CodeFile="Default2.aspx.cs
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script>
$(function(){
var current = new Date();
var pollstartdate = new Date("April 1, 2015 13:00")
var pollenddate = new Date("April 30, 2015 15:00")
if(current.getTime()>=poll
$('#pollvote').show();
$('#pollcommentbox').hide(
}
else if(current.getTime()>=poll
$('#pollcommentbox').show(
$('#pollvote').hide();
}
});
$('#pollvote').show();
</script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="pollvote" style="display:none">
<p>This is where the user will vote #pollvote</p>
</div>
<div id="pollcommentbox" style="display:none">
<p>This is where the user will leave a comment #pollcommentbox</p>
</div>
</form>
</body>
</html>
Right now I have the two dates that I need hard coded, but I will be getting them off another form. How do I pass these parameters into my script?
Where it the entry point, that calls the script? Does that point have access to the parameters from the other form?
ASKER
Yes
Can you show me how you call the script please? On the surface, I would think that you could just add those parameters to the function call, but somehow I am thinking that it won't be that easy.
ASKER
I will have to send that to you in the morning. I am working in another framework called Kentico and I am not sure at the moment how this is going to get called.
Thanks for getting back.
Thanks for getting back.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
In speaking with others using the Kentico framework, there was an alternative to using JQuery. A macro was placed directly into the webpart that was used instead of Jquery.