Skip to main content
Inspiring
October 19, 2006
Answered

Need help with alert

  • October 19, 2006
  • 1 reply
  • 635 views
Hi, this may be a very simple, but I am kinda stuck. I have a grid that gets populated with data. I have an edit button. What I have now is when I select an item from the grid and click the edit button it will take me to another form to edit the data selected. What I wanna do now is, IF I did not select anything from the datagrid, I want an alert message or popup message stating "I need to select an item from the grid or nothing is selected.". What do I need to do to accomplish this. Any help will be very much appreciated.

Ex.
*************MY GRID **************************
<cfgrid name="searchGrid" query="Calls" >
<cfgridcolumn name="Id" header="Call Id" />
<cfgridcolumn name="Name" header="Name" />
and so on.....
</cfgrid>

******MY EDIT BUTTON ***********
<cfinput type = "button" onClick="getUrl('EditCall.cfm?CallId='+searchGrid.dataProvider[searchGrid.selectedIndex]['CallId'])" name="edit" value="Edit" />
    This topic has been closed for replies.
    Correct answer alfie9
    Nevermind I figured it out!!!!

    on my button I did this:

    <cfinput type="button" onClick="if(searchGrid.selectedItem == undefined) alert('No data is selected', 'Error'); else getUrl('EditStore.cfm?StoreId='+searchGrid.dataProvider[searchGrid.selectedIndex]['StoreId'])" name="getStore" value="Edit" />

    Thanx

    1 reply

    alfie9AuthorCorrect answer
    Inspiring
    October 19, 2006
    Nevermind I figured it out!!!!

    on my button I did this:

    <cfinput type="button" onClick="if(searchGrid.selectedItem == undefined) alert('No data is selected', 'Error'); else getUrl('EditStore.cfm?StoreId='+searchGrid.dataProvider[searchGrid.selectedIndex]['StoreId'])" name="getStore" value="Edit" />

    Thanx