Solved

Javascript help

Posted on 2011-09-06
3
185 Views
Last Modified: 2012-05-12
Hi

I have a following function which is executed when a user clicks a button. However, I would like to send an a warning before the function, where I would like to give a message, "Do you want to update the item?" and when user says, 'Yes', then only i want the function to update. Can anyone help me how to achive this using following script below?





function PMapprove(id, value) {

      var pmmsg = "<?xml version='1.0' encoding='utf-8'?> \
            <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://www.w3.org/2003/05/soap-envelope'> \
                  <soap:Body> \
                        <UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                              <listName>AESO Reports Library</listName> \
                                    <updates> \
                                          <Batch OnError='Continue'> \
                                                <Method ID='1' Cmd='Update'> \
                                                      <Field Name='Ready_x0020_for_x0020_Review'>" + value +  "</Field> \
                                                      <Field Name='ID'>" + id + "</Field> \
                                                </Method> \
                                          </Batch> \
                                    </updates> \
                        </UpdateListItems> \
                  </soap:Body> \
            </soap:Envelope>";

      $.ajax({
            url: "myURL/_vti_bin/lists.asmx",
            asynch: false,
            beforeSend: function (xhr) {
                  xhr.setRequestHeader("SOAPAction",
                  "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
            },
            type: "POST",
            dataType: "xml",
            data: pmmsg,
            contentType: "text/xml; charset=\"utf-8\""
      });
      
}
0
Comment
Question by:Techsavy
3 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 250 total points
ID: 36493600
just call this function

function warn(id, value)
{
   if (confirm("Do you want to update the item?") )
   {
      PMapprove(id, value);
   }
}
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36493628
OR use below function
function PMapprove(id, value) {
 if (confirm("Do you want to update the item?") )
   {
      var pmmsg = "<?xml version='1.0' encoding='utf-8'?> \
            <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://www.w3.org/2003/05/soap-envelope'> \
                  <soap:Body> \
                        <UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                              <listName>AESO Reports Library</listName> \
                                    <updates> \
                                          <Batch OnError='Continue'> \
                                                <Method ID='1' Cmd='Update'> \
                                                      <Field Name='Ready_x0020_for_x0020_Review'>" + value +  "</Field> \
                                                      <Field Name='ID'>" + id + "</Field> \
                                                </Method> \
                                          </Batch> \
                                    </updates> \
                        </UpdateListItems> \
                  </soap:Body> \
            </soap:Envelope>";

      $.ajax({
            url: "myURL/_vti_bin/lists.asmx",
            asynch: false,
            beforeSend: function (xhr) {
                  xhr.setRequestHeader("SOAPAction",
                  "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
            },
            type: "POST",
            dataType: "xml",
            data: pmmsg,
            contentType: "text/xml; charset=\"utf-8\""
      });
   }   
}

Open in new window

0
 
LVL 7

Assisted Solution

by:Kishan Zunjare
Kishan Zunjare earned 250 total points
ID: 36494423
Hi,

You can go for this;
<script type="text/javascript">
function show_confirm()
{
var r=confirm(""Do you want to update the item?" ");
if (r==true)
  {
          // Your JS Code
  }
else
  {
  alert("You pressed Cancel!");
  }
}
</script>
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now