Solved

Javascript help

Posted on 2011-09-06
3
199 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 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

687 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