andreshcs
03-11-2006, 08:29 AM
I'm trying to make a pop-up message box where there is a confirmation of yes/no... when user click on a button, this confirmation message box will pop up and showing the value of selection that the user made ( let's say the value is get from the dropdownlist1 )... so the user will either press ok to confirm it or cancel to return to that page... where ok will bring the user to next page... i'm using this code and i'm not sure where i went wrong or i missed out something... thanks...
mainpage.aspx:
<SCRIPT language="javascript">
function getMessage()
{
var ans;
ans=window.confirm('Are you sure?');
//alert (ans);
if (ans==true)
{
//alert('Yes');
document.Form1.hdnbox.value='Yes';
}
else
{
//alert('No');
document.Form1.hdnbox.value='No';}
}
</SCRIPT>
<form id="Form1" method="post" runat="server">
<asp:button id="Button1" style="Z-INDEX: 101; LEFT: 352px; POSITION: absolute; TOP: 152px" runat="server" Height="72px" Width="120px" Text="Button"></asp:button>
<asp:DropDownList id="dropdownlist1" style="Z-INDEX: 102; LEFT: 360px; POSITION: absolute; TOP: 104px" runat="server" Width="112px" AutoPostBack="True">
<asp:ListItem Value="Please Select" Selected="True">Please Select</asp:ListItem><asp:ListItem Value="Pen">Pen</asp:ListItem>
<asp:ListItem Value="Eraser">Eraser</asp:ListItem>
</asp:DropDownList></form>
mainpage.aspx.vb:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onclick", "getMessage()")
Response.Write(Request.Form("hdnbox"))
End Sub
i do feel that there is something wrong with this code... where hsould i improve it or i wrote wrongly ??? please help... thanks a lot guys...
mainpage.aspx:
<SCRIPT language="javascript">
function getMessage()
{
var ans;
ans=window.confirm('Are you sure?');
//alert (ans);
if (ans==true)
{
//alert('Yes');
document.Form1.hdnbox.value='Yes';
}
else
{
//alert('No');
document.Form1.hdnbox.value='No';}
}
</SCRIPT>
<form id="Form1" method="post" runat="server">
<asp:button id="Button1" style="Z-INDEX: 101; LEFT: 352px; POSITION: absolute; TOP: 152px" runat="server" Height="72px" Width="120px" Text="Button"></asp:button>
<asp:DropDownList id="dropdownlist1" style="Z-INDEX: 102; LEFT: 360px; POSITION: absolute; TOP: 104px" runat="server" Width="112px" AutoPostBack="True">
<asp:ListItem Value="Please Select" Selected="True">Please Select</asp:ListItem><asp:ListItem Value="Pen">Pen</asp:ListItem>
<asp:ListItem Value="Eraser">Eraser</asp:ListItem>
</asp:DropDownList></form>
mainpage.aspx.vb:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onclick", "getMessage()")
Response.Write(Request.Form("hdnbox"))
End Sub
i do feel that there is something wrong with this code... where hsould i improve it or i wrote wrongly ??? please help... thanks a lot guys...