Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Javascript help

Posted on 2011-09-06
3
Medium Priority
?
203 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:
Gurvinder Pal Singh 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

636 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