?
Solved

Javascript help

Posted on 2011-09-06
3
Medium Priority
?
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 1000 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 1000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

770 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