Hi,

Can someone help me out with the below problem?

I have a grid and each row has a checkbox as the first column. In case
if they want to edit or send a mail, they can tick the check box and
click the edit button.

In case if they have selected more than one row by ticking the check
box and click on edit, I want to display a message in the client side
saying select only one record.

Since I am using ASP.Net/VB.net I can't use a msgbox as it will be
displayed in the server only.

As I have no experience with script, can someone help me with some
code pls?

Thnx,
Vithya

Re: Help required to script a message by Ayush

Ayush
Thu Jul 26 21:10:53 CDT 2007

[vithyananthy@gmail.com] wrote-:
> Hi,

> Can someone help me out with the below problem?

> I have a grid and each row has a checkbox as the first column. In case
> if they want to edit or send a mail, they can tick the check box and
> click the edit button.

> In case if they have selected more than one row by ticking the check
> box and click on edit, I want to display a message in the client side
> saying select only one record.

If you dont want to allow multiple selections then why are you using checkboxes ? Use
Input:Radio with same name.


Good Luck, Ayush.
--
Windows Script Host Reference : http://snipurl.com/WSH_Reference

Re: Help required to script a message by vithyananthy

vithyananthy
Thu Jul 26 23:18:11 CDT 2007

On Jul 27, 7:10 am, Ayush <"ayushmaan.j[aatt]gmail.com"> wrote:
> [vithyanan...@gmail.com] wrote-:
>
> > Hi,
> > Can someone help me out with the below problem?
> > I have a grid and each row has a checkbox as the first column. In case
> > if they want to edit or send a mail, they can tick the check box and
> > click the edit button.
> > In case if they have selected more than one row by ticking the check
> > box and click on edit, I want to display a message in the client side
> > saying select only one record.
>
> If you dont want to allow multiple selections then why are you using checkboxes ? Use
> Input:Radio with same name.
>
> Good Luck, Ayush.
> --
> Windows Script Host Reference :http://snipurl.com/WSH_Reference

Hi,

Thnx. Client's requirement is to have a check box as to delete and all
they could do so by selecting multiple records.

Vithya


Re: Help required to script a message by Ayush

Ayush
Fri Jul 27 23:59:24 CDT 2007

[vithyananthy@gmail.com] wrote-:
> Thnx. Client's requirement is to have a check box as to delete and all
> they could do so by selecting multiple records.

OK. Then loop through all the checkboxes and check if more than 1 is checked, e.g.:

var chks=document.getElementsByTagName("INPUT"),iX=0,curr,count=0;
while(curr=chks[iX++])
if(curr.type=="checkbox" && curr.checked)
count++;
if(count>1)alert('Please select only 1 record.')
return 0

Good Luck, Ayush.
--
Scripting Solutions Center : http://snipurl.com/Scripting_Solutions

Re: Help required to script a message by vithyananthy

vithyananthy
Mon Jul 30 03:39:12 CDT 2007

On Jul 28, 9:59 am, Ayush <"ayushmaan.j[aatt]gmail.com"> wrote:
> [vithyanan...@gmail.com] wrote-:
>
> > Thnx. Client's requirement is to have a check box as to delete and all
> > they could do so by selecting multiple records.
>
> OK. Then loop through all the checkboxes and check if more than 1 is checked, e.g.:
>
> var chks=document.getElementsByTagName("INPUT"),iX=0,curr,count=0;
> while(curr=chks[iX++])
> if(curr.type=="checkbox" && curr.checked)
> count++;
> if(count>1)alert('Please select only 1 record.')
> return 0
>
> Good Luck, Ayush.
> --
> Scripting Solutions Center :http://snipurl.com/Scripting_Solutions

Hi Ayush,

Thnx.

I have put your code in my source as below
<script type ="text/javascript" >
var
chks=document.getElementsByTagName("INPUT"),iX=0,curr,count=0;
while(curr=chks[iX++])
if(curr.type=="checkbox" && curr.checked)
count++;
if(count>1)alert('Please select only 1 record.')
return 0
</script>

But, nothing happens what i did wrong?

I have a script like the below

<script type ="text/javascript" >
function ValSelectedRows(e) {
var targ;

if (!e) var e = window.event;
targ = (e.target) ? e.target : e.srcElement;
if (targ.nodeType == 3) targ = targ.parentNode;

if (targ.id.toLowerCase().indexOf("img") >= 0) {
return confirm("Please select only one row to continue.");
}
routeEvent(e);
}

document.onclick = ValSelectedRows;
</script>

Above is working, but the problem is, when ever i clicked on the edit
button, regardless of the no. of records selected, it is always popped.


Re: Help required to script a message by vithyananthy

vithyananthy
Mon Jul 30 03:57:11 CDT 2007

On Jul 30, 1:39 pm, vithyanan...@gmail.com wrote:
> On Jul 28, 9:59 am, Ayush <"ayushmaan.j[aatt]gmail.com"> wrote:
>
>
>
>
>
> > [vithyanan...@gmail.com] wrote-:
>
> > > Thnx. Client's requirement is to have a check box as to delete and all
> > > they could do so by selecting multiple records.
>
> > OK. Then loop through all the checkboxes and check if more than 1 is checked, e.g.:
>
> > var chks=document.getElementsByTagName("INPUT"),iX=0,curr,count=0;
> > while(curr=chks[iX++])
> > if(curr.type=="checkbox" && curr.checked)
> > count++;
> > if(count>1)alert('Please select only 1 record.')
> > return 0
>
> > Good Luck, Ayush.
> > --
> > Scripting Solutions Center :http://snipurl.com/Scripting_Solutions
>
> Hi Ayush,
>
> Thnx.
>
> I have put your code in my source as below
> <script type ="text/javascript" >
> var
> chks=document.getElementsByTagName("INPUT"),iX=0,curr,count=0;
> while(curr=chks[iX++])
> if(curr.type=="checkbox" && curr.checked)
> count++;
> if(count>1)alert('Please select only 1 record.')
> return 0
> </script>
>
> But, nothing happens what i did wrong?
>
> I have a script like the below
>
> <script type ="text/javascript" >
> function ValSelectedRows(e) {
> var targ;
>
> if (!e) var e = window.event;
> targ = (e.target) ? e.target : e.srcElement;
> if (targ.nodeType == 3) targ = targ.parentNode;
>
> if (targ.id.toLowerCase().indexOf("img") >= 0) {
> return confirm("Please select only one row to continue.");
> }
> routeEvent(e);
>
> }
>
> document.onclick = ValSelectedRows;
> </script>
>
> Above is working, but the problem is, when ever i clicked on the edit
> button, regardless of the no. of records selected, it is always popped.- Hide quoted text -
>
> - Show quoted text -

Hi Ayush,

I coded like the below then it is working
<script type ="text/javascript" >
function ValSelectedRows(e) {
var
chks=document.getElementsByTagName("INPUT"),iX=0,curr,count=0;
while(curr=chks[iX++])
if(curr.type=="checkbox" && curr.checked)
count++;
if(count>1) alert('Please select only 1 record.')
return 0

var targ;

if (!e) var e = window.event;
targ = (e.target) ? e.target : e.srcElement;
if (targ.nodeType == 3) targ = targ.parentNode;

if (targ.id.toLowerCase().indexOf("img") >= 0) {
return confirm("Please select only one row to continue.");
}
routeEvent(e);
}

document.onclick = ValSelectedRows;
</script>

But, I can click on the edit button when multiple items are selected.
Can I control this behaviour?


Re: Help required to script a message by Ayush

Ayush
Mon Jul 30 09:22:07 CDT 2007

[vithyananthy@gmail.com] wrote-:
> I have put your code in my source as below
> <script type ="text/javascript" >
> var
> chks=document.getElementsByTagName("INPUT"),iX=0,curr,count=0;
> while(curr=chks[iX++])
> if(curr.type=="checkbox" && curr.checked)
> count++;
> if(count>1)alert('Please select only 1 record.')
> return 0
> </script>

> But, nothing happens what i did wrong?

> I have a script like the below

Can you post the HTML content ?



Good Luck, Ayush.
--
Script Center-Script Repository : http://snipurl.com/Script_Repository

Re: Help required to script a message by vithyananthy

vithyananthy
Tue Jul 31 00:03:42 CDT 2007

Hi,

Below is the HTML content

<%@ Page Language="VB" MasterPageFile="~/tbmain.master"
AutoEventWireup="false" CodeFile="tbSentReg.aspx.vb"
Inherits="tbSentReg" title="TeamBinder by QA Software"
StylesheetTheme="tbSkin" %>
<asp:Content ID = "tbSentRegContent" ContentPlaceHolderID="tbContent"
Runat="Server">
<script type ="text/javascript" >
function ValSelectedRows(e) {
var
chks=document.getElementsByTagName("INPUT"),iX=0,curr,count=0;
while(curr=chks[iX++])
if(curr.type=="checkbox" && curr.checked)
count++;
if(count>1) alert('Please select only 1 record.')
return 0

var targ;

if (!e) var e = window.event;
targ = (e.target) ? e.target : e.srcElement;
if (targ.nodeType == 3) targ = targ.parentNode;

if (targ.id.toLowerCase().indexOf("img") >= 0) {
return confirm("Please select only one row to continue.");
}
routeEvent(e);
}

document.onclick = ValSelectedRows;
</script>

<table id="tblMailRegInBoxToolbar">
<tr>
<td style="width: 15%">
<asp:ImageButton ID="ImgBtnForward" runat="server"
ImageUrl="~/Images/tbForward.gif" ToolTip="Forward" />
<asp:ImageButton ID="ImgBtnDuplicate" runat="server"
ImageUrl="~/Images/TBNewDup.gif"
ToolTip="Duplicate" />
<asp:ImageButton ID="ImgBtnClose" runat="server"
BorderStyle="Solid" ImageUrl="~/Images/TBClose.gif"
ToolTip="Close" /></td>
</tr>
</table>
<asp:GridView ID="grdMailRegSent" runat="server"
AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" GridLines="None" Height="128px"
SelectedRowStyle-BackColor="#FF0033"
Width="100%" AllowSorting="True">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="ChkSelect" runat="server"
int_Key='<%#Eval("int_Key") %>' />
</ItemTemplate>
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="5%" />
</asp:TemplateField>
<asp:TemplateField HeaderImageUrl="~/IMAGES/tbAtt.gif">
<ItemTemplate>
<asp:Image ID="ImgAttLink" runat="server"
ImageUrl='<%#iif((Eval("Attachlink")=1),"~/IMAGES/tbAtt1.gif", "~/
IMAGES/qablank.gif") %>' />
</ItemTemplate>
<HeaderStyle BackColor="Navy" Width="5%" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="ImgPriority" runat="server"
ImageUrl='<%#iif((Eval("Priority")=2),"~/IMAGES/tbHighPriority.gif",
"~/IMAGES/qablank.gif") %>' />
</ItemTemplate>
<HeaderStyle BackColor="Navy" Width="5%" />
</asp:TemplateField>
<asp:BoundField DataField="type" HeaderText="Type">
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="10%" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small"
Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="documentno"
HeaderText="Document No">
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="15%" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small"
Width="15%" />
</asp:BoundField>
<asp:BoundField DataField="Received" HeaderText="Date
Time">
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="10%" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small"
Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="Dt_Rcvd" HeaderText="Date
Read">
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="10%" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small"
Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="subject" HeaderText="Subject">
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="25%" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small"
Width="25%" />
</asp:BoundField>
<asp:BoundField DataField="toid" HeaderText="To Id">
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="5%" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small"
Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="tocompid" HeaderText="To
CompId">
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="5%" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small"
Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="fromid" HeaderText="From Id">
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="5%" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small"
Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="fromcompid" HeaderText="From
CompId">
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="5%" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small"
Width="5%" />
</asp:BoundField>
<asp:BoundField DataField="status" HeaderText="Status">
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="10%" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small"
Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="respondby" HeaderText="Respond
By">
<HeaderStyle BackColor="Navy" Font-Names="Verdana"
Font-Size="Small" ForeColor="White"
Width="10%" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small"
Width="10%" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />
<EditRowStyle BackColor="#7C6F57" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle BackColor="#0A246A" Font-Bold="True"
ForeColor="White" HorizontalAlign="Left"
VerticalAlign="Top" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</asp:Content>