How to use window.confirm in a JavaScript with unknown variables

On my delete category page the user can pick the category it wishes to delete from a dropdown list (which is generated by rows in my database).
When the user hits the "Delete" button ths OnClick runs a JavaScript that sends the delete request to a .jsp page that handles all my insert, update and delete queries.
<input name="delete" type="button" id="delete" onClick="post('delete');return false;" value="Delete">
function post(actValue)
     document.MyForm.action.value = actValue ;
     document.MyForm.submit() ;
}So far, so good. But:
Before the site goes to this last jsp page I want a pop-up window that ask's for a confirmation of the delete-request.
So I changed the OnClick and I made another JavaScript::
<input name="delete" type="button" id="delete" onClick="delete('categoryName');return false;" value="Delete">
function deleteConfirm(categoryName)
     if( window.confirm("Are you sure you want to delete: " + categorieNaam + "?") == true)
          post('delete');
          return false;
}The problem is, when the page is loaded, we don't know yet what category the user wants to have deleted. So categoryName is unknown.
How can I make this work?

You have the category in a dropdown list?
<select name="catToDelete">
<option value="cat1">cat1</option>
<option value="cat2">cat2</option>
<option value="cat3">cat3</option>
</select>
You can use javascript attributes such as
var toDelete = document.all.catToDelete;
// the value it will submit
var selectedValue = toDelete.value;
// the selected index
var selectedIndex = toDelete.selectedIndex;
// the option that is selected
var selectedOption = toDelete.options[selectedIndex];
// the text of that option
var theText = selectedOption.textYou should be able to extract the info you need from that I hope.
Cheers,
evnafets

Similar Messages

  • How To use window.print() into Button Attributes

    hi,
    I want to print a report using an print button.so i am using window.print() function into Button Attributes .But Print pop up screen not pop up . How To use window.print() into Button Attributes      .
    Thanks
    Manoj

    dear hari
    "Set button target as URL and put following js as URL Target
    javascript:window.print();"
    Will this be useful to my another thread raised as follows.
    In case, if i am able to generate report as txt (ascii) file instead of doc / pdf and is it possible to send the txt file using host command. I am uable to try since i do not know where to place host command on click &print.
    yours
    dr.s.raghunathan

  • How to use an if statement in javascript code

    Hello,
    I have a batch processing script to search for text "employee signature" on each page in a multiple page file and to then list in the console any pages that do not have the "Employee Signature" text included.
    The script is not yet functional as an if statement needs to be included.
    Can anyone please advise how to use an if statement in javascript code?
    var numpages = this.numPages;
    for (var i=0; i < numpages; i++)
    search.query("Employee Signature", "ActiveDoc");
    console.println('Pages that do not include an employee signature: ' + this.pageNum +' ');
    Any assistance will be most appreciated.

    Thank you very much for your assistance try.
    I have modified the code as suggested and the page numbers are now listing correctly, thank you, but....................,
    The console  lists every page as having an "employee signature" when there are pages in the document that do not have an employee signature.
    The code (revised as follows) is not processing the "getPageNthWord part of the statement" in the console report?
    Can you please advise where the code needs reworking?
    var ckWords; // word pair to test
    var bFound = false; // logical status of found words
    // loop through pages
    for (var i = 0; i < this.numPages; i++ ) {
       bFound = false; // set found flag to false
       numWords = this.getPageNumWords(i); // number of words on page
       // loop through the words on page
       for (var j = 0; j < numWords; j++) {
          // get word pair to test
          ckWords = this.getPageNthWord(i, j) + ' ' + this.getPageNthWord(i, j + 1); // test words
          // check to see if word pair is 'Employee' string is present
          if ( ckWord == "Employee") {
             bFound = true; // indicate found logical value
             console.println('Pages that includes an employee signature: ' + (i + 1) +' ');
             break; // no need to further test for this page
          } // end Employee Signature
       } // end word loop
       // test to see if words not found
       if(bFound == false) {
             console.println('Pages that do include an employee signature: ' + (i + 1) +' ');
        } // end not found on page  
    } // end page loop
    Thank you

  • How to Use Windows XP theme in Java

    How to Use Windows XP theme in Java.
    I am an developing application which L&F should be like Windows XP.
    Because I am going use this application in different OS.
    Which LookAndFeel I have to use it

    try this in main:
    try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}
    catch (Exception exc) {System.err.println("Eroare la incarcarea look & feel" + exc);}

  • How to download itunes and how to use windows in my iPad?

    How to download itunes and how to use windows in my iPad?

    The iTunes  app comes pre installed on your iPad.
    Use Windows? The iPad is an iOS device. Not possible to run Windows on an iPad.

  • How to use collective confirmation CO12

    can any body explain me how to use collective confirmation CO12 with screen dump.
    Plz help

    Hi Viswa,
    Prerequisites:
    You can predefine values to identify confirmations and to determine default values in Conf. parameters for collective confirmation/fast entry (Customizing for Shop Floor Control by choosing Operations ® Confirmation ® Confirmation Parameters Collective Entry/Fast Entry):
        Identifying the confirmation
    You can identify an individual confirmation either by the confirmation number or the order number/operation number.
        Suggest actual data
    You can define whether and when (after entry, during saving) quantities (see Determining a Default for Yield) or activities are suggested. The default setting is that no quantities are suggested and activities are determined during saving. Personnel data and dates are always suggested.
    Procedure:
        Choose Logistics ® Production ® Shop floor control ® Confirmation ® Enter ® For operation ® Collective entry.
        The screen for collective entry of confirmations appears.
        In this screen you can enter confirmations in a table (table control). You enter a new confirmation in each line. You can control the appearance of the table yourself.
    You can change the type of confirmation identification during input. To do so choose Other view.
    Enter all the data needed for the confirmations. Each line corresponds to a new confirmation. In this line you have all the fields that are available in single entry of a time ticket confirmation.
    On the top line of the screen you can enter default values (for example unit of measure, personnel number) that are copied to all confirmations. Enter the values and choose This graphic is explained in the accompanying text. You can save these default values for a specific user, so that they are preset the next time the user logs on. You can also delete these defaults.
    With this function, you can let the system suggest actual data (quantities, activities, dates, personnel data). To do so, select the confirmations, choose This graphic is explained in the accompanying text Propose actual data, set the indicator for the relevant actual data and choose This graphic is explained in the accompanying text. This data overwrites data that you may have already entered.
        Save your confirmations.
    Note
    To reach the Actual data screen for the selected confirmations choose This graphic is explained in the accompanying text. Here you have the complete functionality of time ticket confirmation. From this screen you can go to the detail screens and to the goods movement overview. If several confirmation have been selected, you can switch between the individual confirmations.
    Note
    You can switch to the goods movement overview from the collective entry screen (choose This graphic is explained in the accompanying text Goods movements). In this screen the goods movements for the selected confirmations are displayed.
    You can check and, if necessary, change the goods movements. When you go back to the collective entry screen, the GM indicator is set for the selected confirmations (goods movements for confirmations already determined). As soon as you save a confirmation, the goods movements are also posted.
    For more information choose the GOODS MOVEMENT OVER VIEW.
    Regards,
    Madhu.G
    Edited by: madhu333mac on Jan 11, 2012 11:34 PM

  • How to install Windows 8 on Macbook pro with retina display ?

    Hi - How to install Windows 8 on Macbook pro with retina display ?
    I am pretty new to the apple world. Tried doing it through bootcamp but did not success.
    I am not interested to install it through Parallels or Fusion. Plz guide.
    Thanks !

    OK, use Windows 8 in Bootcamp. Be aware that there are no Bootcamp drivers for Windows 8 yet. So you may experiance not only delays but display problems, freezing, crashes and other problems.
    Here is the Bootcamp forum. Make sure you read all the posts from people experiencing Windows 8 problems with Bootcamp. https://discussions.apple.com/community/windows_software/boot_camp

  • Req any examples of how to use a USB midi controller​/keyboards with Labview TIA

    Req any examples of how to use a USB midi controller/keyboards with Labview TIA

    Hi,
    To access the MIDI ports you will need to call the Windows SDK. To send MIDI commands is relatively easy, here is an example that shows you how to send data to a MIDI controller or keyboard.
    As far as input goes, this is the hard part. There are a series of functions that you need to call to open up the device, set some buffers and and possibly a callback to get notifications on the incoming data.
    Reading MIDI data will not be an easy task, your best bet will be to implement this in a DLL and call that DLL in LabVIEW, there should be some code available o the web.
    = "http://msdn.microsoft.com/library/default.asp?url​=/library/en-us/multimed/htm/_win32_multimedia_... is a link to the Windows multimedia functions that you could use for MIDI input.
    Let me know if you have any further questions.
    Regards,
    Juan Carlos
    N.I.

  • I have lightroom 5 with 5.7 updated.   I use windows.  My problem is with the spot healer or remover.  It worked perfectly when I click on it it don't have the additional circle with a line attached to it where I can move it to another place for better sa

    I have lightroom 5 with 5.7 verson updated.  I use windows.  My problem is with the spot healer or remover in the develop.  It worked perfectly for a while and then suddenly the other circle with a line attached to it where you can move it to a better spot stopped showing up.  I uninstalled the software and re installed it again but it didn't fix the problem and its still the same.  Help please.

    Does the iPod work OK?
    Does it charge when connect to the computer?
    Does it appear in My Computer?
    Look at the dock connector on the iPod. Compare with the iPod that does work/connect.
    I suspect you have a 2G iPod. Those can only go to iOS 4.2.1
    http://support.apple.com/kb/HT1353#iPod_touch_late2009
    iPod touch (3rd generation)
    iPod touch (3rd generation) features a 3.5-inch (diagonal) widescreen multi-touch display and 32 GB or 64 GB flash drive. You can browse the web with Safari and watch YouTube videos with Wi-Fi. You can also search, preview, and buy songs from the iTunes Wi-Fi Music Store on iPod touch.
    The iPod touch (3rd generation) can be distinguished from iPod touch (2nd generation) by looking at the back of the device. In the text below the engraving, look for the model number. iPod touch (2nd generation) is model A1288, and iPod touch (3rd generation) is model A1318.

  • How to Use SQL Query having IN Clause With DB Adapter

    Hi,
    I am using 11.1.1.5 want to find out how to Use SQL Query having IN Clause With DB Adapter. I want to pass the IN values dynamically. Any ideas.
    Thanks

    invoke a stored procedure, it's safer than trying to put together an arbitrary SQL statement in the JCA adapter

  • How to use 45W MagSafe 2 Power Adapter with cable management MagSafe 2 power port macbook air 2013

    How to use 45W MagSafe 2 Power Adapter with cable management MagSafe 2 power port macbook air 2013 there's two plugs do I use both for the safety to work or I just one ? Thanks sorry new macbook air 2013 was given to my daughter fir her 18th bday 2 days ago by my brother

    No, the one is just an extension cord,          just use the 45W charger with its attached thin cord and connect the magnetic magsafe to to the connector on the back left of the macbook Air for use and charging it

  • In SQLScript, how to use EXEC to call another procedure with parameters in procedure?

    Hi experts,
    In SQLScript, How to use EXEC to call another procedure with input and output parameters in procedure?thanks very much

    Hi Sagar,
    thank you! I generate another procedure with an input parameter and an output parameter in a procedure. Then i need to call the generated procedure using EXEC. Here is my code:
    create procedure ftest1(out sum_num bigint)
    as
    begin
    declare fa_output bigint;
    declare v_sql_drop varchar(200);
    declare v_sql varchar(500);
    declare cursor c_cursor1 for select num from TABLE1;
    --v_sql_drop := 'drop procedure fe';
    --exec v_sql_drop;
    v_sql := 'create procedure fe(in i_num bigint,out o_num bigint) as begin';
    v_sql := :v_sql || ' o_num := :i_num * 2 + :i_num * :i_num;';
    v_sql := :v_sql || ' end';
    exec v_sql;
    open c_cursor1;
    for c_item as c_cursor1 do
    exec 'call fe(c_item.num,o_num=>fa_output)';
    if sum_num is null then
    sum_num := fa_output;
    else
    sum_num := :sum_num + fa_output;
    end if;
    end for;
    close c_cursor1;
    end;
    The underline code is using exec to call the generated procedure. But this method cannot work. Any suggestion? thanks again!

  • How to view windows Xp formatted hard drive with Macbook pro without losing data

    How to view Windows Xp programed Hard drive with Macbook pro with out losing data on hardrive

    Go to the First Aid tab in Disk Utility, select the external drive partition and read the format from the lower left, at the bottom.

  • How to use Mac Mini Server as NAT with only one port??

    How to use Mac Mini Server as NAT with only one ethernet port??

    But why did apple sell me this server that does NAT with one port? I don't get it.

  • How to Use Mobile Service in HTML/JavaScript Application

    The Windows Azure Mobile Service is a back end tool for mobile applications. It supports various platforms, such as Windows Store, Windows Phone 8, iOS and Android. The Windows Azure
    Mobile service can also support HTML/JavaScript. This article helps you to get a basic idea of how to use the Windows Azure Mobile Service in HTML/JavaScript applications.
    Let us start with a Quick startup project provided by Microsoft. A Quick startup is a simple demo project that can help us to understand how to use the Windows Azure Mobile Service with HTML/JavaScript. So let's start from the Quick startup project.
    Login into in the Windows Azure portal and use the following procedure.
    This article assumes you already have a Windows Azure account and the mobile service is enabled in your account.
    1. Create a new Windows Azure Mobile Service
    Click on the +New button from the left corner and select Compute -> Mobile Service and then click on the "Create" button.
    The Windows Azure portal popup creates a mobile service wizard when you click the Create button. Windows Azure asks you to enter the mobile service name as shown in the following image:
    Select the database options and region for your mobile service and click on the "Next" button.
    Once your mobile service is successfully created, the portal will show all your mobile services as shown in the following images.
    Ok! We have created a new mobile service successfully. Let's move to our subsequent steps.
    1. Quick startup Project 
    As we all know, the Windows Azure Mobile Service can support many platforms such as Windows Store, Windows Phone 8, iOS, Android and HTML/JavaScript. This article only tells us about the new HTML/JavaScript platform that is recently added to the Windows Azure
    Mobile Service.
    In the image above, we are in the quick startup page where the Windows Azure Mobile Service allows the user to choose their platform. I have selected the HTML/JavaScript Platform.
    In the image above, we found 3 quick steps that can allow us to run <g class="gr_ gr_74 gr-alert gr_gramm Grammar" data-gr-id="74" id="74">a HTML/JavaScript</g> sample project. 
    1. Create Table: In this step the user needs to create a table that can used by the sample project, once you hit the create TodoItem Table button. The Portal will create a TodoItem table in your mobile service. You
    can check this table by clicking on the data tab(menu).
    2. Download and run your app: In this step the user needs to download the Quick startup project that is provided by the Windows Azure portal. Click on the "Download" button and download the project. You will
    see the following files in the quick startup project.
    The Server folder contains some files to setup this project locally. The user should run the file from the server folder corresponding to their OS. I am using Windows OS so I ran the <g class="gr_ gr_80 gr-alert gr_spell ContextualSpelling ins-del multiReplace"
    data-gr-id="80" id="80">lanch</g>-<g class="gr_ gr_79 gr-alert gr_spell ContextualSpelling ins-del multiReplace" data-gr-id="79" id="79">windwos</g> file to setup this project locally in
    IISExpress.
    Press r and enter the key, you will see IISExpress started. Do not close this Windows and open your browser and request the http://localhost:8000/ page.
    Enter the Item name and click on the add button. Your Item will be added to the TodoItem table.
    3. Configure your host name: This step is a very important step for any HTML/JavaScript application that uses the Windows Azure Mobile Service. In this <g class="gr_ gr_83 gr-alert gr_gramm Punctuation only-ins
    replaceWithoutSep" data-gr-id="83" id="83">step</g> the user must register their website name in the Cross-origin resource sharing (CORS). By default, "localhost" is added by the Windows Azure Mobile Service
    so your quick startup project can run without making any CORS setting changes. The user can add their website domain name by clicking on the configure tab (menu).
    The user can add as many website domain names as needed.

    are you asking a question or did you just post a tutorial here? you might want to post it as a blog post or wiki entry instead.

Maybe you are looking for