...

View Full Version : need javascript/ASP help with how to make button to run 2 actions



shandralyn
05-04-2004, 09:35 PM
I am new to javascript and I want to create a button for an ASP/web application I'm working on that will 1) prompt for two variables, startdate and enddate and 2) send them and a few other variables in a querystring to a new url. I thought it might be easiest with javascript. But if there is a better way to do this I am open to any ideas. So I would appreciate any help, links or advice. My current code attempt for the button is below:


<button name="show_range" type="button" style="width: 99; height: 26" onClick="return Run_My_Function()">
<a href="show_range.asp?Identifier=<%=strIdentifier%>&EmplID=<%=strEmplID%>&EmplName=<%=Server.URLEncode(strEmplName)%>&EmplEmail=<%=Server.URLEncode(strEmplEmail)%>">
View Range </a>
</button>

<script type="text/javascript">
function My_Function()
{
var startdate = prompt("Please enter start date","")
var enddate = prompt("Please enter end date","")
}
</script>

Choopernickel
05-05-2004, 02:47 PM
Would shandralyn or a kindhearted moderator please edit that post to wrap the code in [ code] tags? I've got some serious side-scrolling action here.

shandralyn
05-05-2004, 04:30 PM
I didn't know about code tags, but now I put them in.

shandralyn
05-05-2004, 07:02 PM
I think my problem was in trying to include both the onClick run function and the hyperlink within the button tags. So I put the command to go to the new url in the function and it seems to work now :thumbsup:



<button name="show_range" type="button" style="width: 99; height: 26" onClick="return My_Function()">
View Range </button>

<script type="text/javascript">
function My_Function()
{
var startdate = prompt("Please enter start date","")
var enddate = prompt("Please enter end date","")
window.location="show_range.asp?Identifier=<%=strIdentifier%>&EmplID=<%=strEmplID%>&EmplName=<%=Server.URLEncode(strEmplName)%>&EmplEmail=<%=Server.URLEncode(strEmplEmail)%>"
return
}
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum