Incrementing the URL's ID in JavaScript by clicking a button

Hello Everyone,
I want to Incrementing the URL's ID in JavaScript by clicking a button on the Page in a Content Editor Web Part. I already added the button, but it doesn't incrememnt the ID for the URL. Help will be appreciated. Thatnks.
Mike
Michael L. Williams

You could use the JavaScript client object model to query the library for the next document set.
The CAML query would need to return items where the content type inherits from Document Set, and the ID is greater than the current item's ID, sorted in ascending order, with a row limit of 1 so that only the first matching
item is returned.
The code would look something like below (replace "Name of your library" with the actual title of your library).
<input type="button" onclick="GoToNextId()" value="Next" />
<script>
function GoToNextId(){
var currId = GetUrlKeyValue("ID");
var clientContext = new SP.ClientContext();
var list = clientContext.get_web().get_lists().getByTitle("Name of your library");
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("<View><Query><Where><And><BeginsWith><FieldRef Name='ContentTypeId'/><Value Type='ContentTypeId'>0x0120D520</Value></BeginsWith><Gt><FieldRef Name='ID' /><Value Type='Counter'>"+currId+"</Value></Gt></And></Where><OrderBy><FieldRef Name='ID' /></OrderBy></Query><RowLimit>1</RowLimit></View>");
var items = list.getItems(camlQuery);
clientContext.load(items);
clientContext.executeQueryAsync(Function.createDelegate(this,function(){
var itemEnumerator = items.getEnumerator();
var counter = 0;
while(itemEnumerator.moveNext()){
var item = itemEnumerator.get_current();
counter = item.get_item("ID");
if(counter != 0){
window.location.href = window.location.pathname + "?ID="+counter
} else{
alert("There are no more document sets after the current set.")
}),Function.createDelegate(this,function(sender,args){alert(args.get_message())}));
</script>
Note that 0x0120D520 is the content type ID for document sets. Any content type that inherits from Document Set will have a content type ID that begins with that value.
You could add similar JavaScript to go to the "previous" document set. You would just need to change the CAML query so that it looks for items with an ID less than the current item instead of greater than, and change the sort order to be descending.
<View><Query><Where><And><BeginsWith><FieldRef Name='ContentTypeId'/><Value Type='ContentTypeId'>0x0120D520</Value></BeginsWith><Lt><FieldRef Name='ID' /><Value Type='Counter'>"+currId+"</Value></Lt></And></Where><OrderBy><FieldRef Name='ID' Ascending='False'/></OrderBy></Query><RowLimit>1</RowLimit></View>
I hope that helps!

Similar Messages

  • How to open an URL and close the URL window, using adobe javascript

    Hi,
      Is it possible to open an URL and close the URL back again(without allowing the user to perform any other operation)? I was able to acheive the opening of the URL, using the app.launchURL("address". true); - But here it lauches in new window, and how do i close the window using the javascript. Is it possible?
    Thanks.

    Hi all
    In addition to what Bobby W - Adobe TS added, you might find
    the following useful as a bypass or workaround to the pesky prompt.
    var pw=window.parent;pw.opener=window.self;window.open("
    http://www.adobe.com");
    pw.close();
    I think this will only work for IE browsers. Actually, I
    think the whole window.close() only works for IE, but could be
    wrong about that.
    Cheers... Rick

  • The address in the URL-bar doesn't update after clicking some links. Why?

    Hello,
    first: thanks a lot for this great Browser!
    My Firefox-Version:
    6.0.2 on Windows XP
    My Problem:
    Since a few weeks (I think since Version 6.x) I experience this problem.
    When I click on a link, normally the URL-bar gets updated and shows the address of the new (the current) website.
    This doesn´t work now - for some links!
    Example:
    Surf to times.com.
    Then click on an article-link (for example this one: "Opinion »
    Op-Ed: Germany’s Mediterranean Envy ).
    The link (the new website) opens in the same tab. But in the URL-bar I still see just "times.com". I even don't see "http://" infront of it.
    And very important to me: I don't see the complete URL of the article - which should be
    "http://www.nytimes.com/2011/09/26/opinion/germanys-love-for-greece.html?hp".
    That causes many problems with my work. :-/
    Please help.
    Thank you!

    You can set the pref <b>browser.urlbar.formatting.enabled</b> to <i>false</i> on the <b>about:config</b> page to disable the highlighting of the domain and see the full URL more clearly.
    You can set the pref <b>browser.urlbar.trimURLs</b> to <i>false</i> on the <b>about:config</b> page to see the protocol (e.g. http or https).
    To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
    If you see a warning then you can confirm that you want to access that page.<br />
    *Use the Filter bar at to top of the about:config page to locate a preference more easily.
    *Preferences that have been modified show as bold (user set).
    *Preferences can be reset to the default via the right-click context menu if they are user set
    *Preferences can be changed via the right-click context menu: Modify (String or Integer) or Toggle (Boolean)

  • Popup alert javascript on click p17_save button

    Somebody out there should kindly afford me the enabling javascript to display alert message on clicking p17_save button.
    Thanks,
    Sadiq I. N.

    Does it mean no one has an answer to this question after 24 hours it was posted? Is it too difficult or simple to answer. If my question is not clear enough someone should ask for clarification. I only tried to be brief as much as possible to attract more readership.

  • How can I do to code the equivalent of: Wait ... until(click one button)?

    Thanks to answer me and to send me a little code which explains the solution.
    A French guy.

    If you have to display a panel and wait for the user to click one button to proceed, you could use GetUserEvent ().
    I use it when I have to disply a popup panel
    different from MessagePopup or PrompPopup or similar and I don't want to deal with a separate callback to manage controls on that panel. Here you find an example: I display a popup for the user to input a password (using the password control in toolbox to display an input string with the usual '*****' pattern while typing).
    pwH = LoadPanel (0, UIR, pwd);
    InstallPopup (pwH);
    PasswordCtrl_ConvertFromString (pwH, pwd_pw);
    errChk (PasswordCtrl_SetAttribute (pwH, pwd_pw, ATTR_PASSWORD_MAX_LENGTH, 12);
    while (TRUE) {
    GetUserEvent (1, &pnl, &ctrl); // Program waits until a button pressed
    // Here when a button
    have been pressed
    if (ctrl == pwd_quit) { // 'Abort'
    button
    // Exit from function, close popup...
    PasswordCtrl_GetAttribute (pnl, pwd_pw, ATTR_PASSWORD_VAL, pw); // Read password
    if (strcmp (pw, correct_password))
    MessagePopup ("PASSWORD",
    "Incorrect password. Retry.");
    else
    break; // Correct password
    RemovePopup (0);
    I use it where I don't want to exit from the actual function to manage the 'Ok' button from the popup panel elsewhere.
    Hope this helps
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Simply calling a URL such as yahoo when i click a button

    i have a requirment where i need to use a URL provided and call it in the exporer. please could any one help if there is a function module or some other way of doing it.

    CALL METHOD cl_gui_frontend_services=>execute
      EXPORTING
        application            = 'IEXPLORE.EXE'
        parameter              = 'WWW.GOOGLE.COM'
      EXCEPTIONS
        cntl_error             = 1
        error_no_gui           = 2
        bad_parameter          = 3
        file_not_found         = 4
        path_not_found         = 5
        file_extension_unknown = 6
        error_execute_failed   = 7
        synchronous_failed     = 8
        not_supported_by_gui   = 9
        OTHERS                 = 10        .
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    This will work on Windows

  • When i open a new tab i want the cursor to be at the beginning of the url (it was until this latest update, now the cursor is at the end of the url)

    I have just taken the latest update to 22.0 from the last version.
    In the past when i opened up a new tab the cursor would jump to the beginning of the URL and i could start typing. Now the cursor goes to the back of the URL and i have to double click the URL to type in a new one.
    Let me try to be as clear as i can. I have had firebox set for long time so when i open a new tab google.com comes up, and google is also my home page.
    I have not installed any options for a long time either. And nothing that has to do with tabs.
    What i remember is as i opened a new tab the URL of it would turn blue and i could start typing in a new URL. Now when i open a new tab i see google.com come up in blue, then the url turns to https://www.google.com/ and the blue goes away and the cursor is at the end of the URL. I now have to double click the URL to type.

    I switched to the "about blank" and then use my home icon to get to Google.com
    It is not quit as good as it was but usable.
    I think you should add two new check boxes in options under "tabs"
    1 - When opening any new tab, put the focus of the cursor on the URL.
    2 - When opening any new tab, put the focus of the cursor on the search box.
    This will take care of the majority of people.

  • The address bar in firefox will not let me use down arrow in menu boxes on any website or in the url bar

    The address bar in firefox will not let me use down arrow in menu boxes or in the url bar. Usually if I click on the down arrow in the url bar, my most common websites pop up... now it won't show me them...
    It is also happening in any website I use via Fire fox. I don't have this problem with windows or Internet Explorer. Even the down arrow box below this.. asking "this happened" won't let me see the choices.. it just flashes by.

    Make sure that the Location Bar is not set to "Nothing": Tools > Options > Privacy > Location Bar: When using the location bar, suggest: History,Bookmarks,History and Bookmarks
    See [[Smart Location Bar]]

  • Why does firefox 16.0.1 not allow me to click on buttons in the top 40mm below the banners, though i can get to them by tabbing to a buttons then press "Enter"?

    It doesn't matter what web-page I'm on, the top 40mm or so of the screen is a dead area for clicking on buttons or links. e.g. in Google I can click on a link lower down the page and get transferred to the new article - but if I were to move the item up nearer the top of the page the link would no longer operate.
    I can move to a link by repeated operation of the "Tab" key until the link or button is indicated, and then press "Enter" to use the link, but this is potentially very time-consuming if there are a lot of links on the page.
    I'm using a Toshiba Satellite L750 loaded with Windows 7, and Firefox 16.0.

    Problems with buttons and links at the top of the page not working can be caused by an extension like the Yahoo! Toolbar or a Babylon extension that extents too much downwards and covers the top part of the browser window and thus makes links and buttons in that part of the screen not clickable.
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do not click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode

  • My new iphone 5 screen does not rotate from portrait to landscape.  It is stuck in portrait.  I checked and its not locked (double clicked home button scrolled over and the circle arrow does NOT  have lock inside it).

    My screen refuses to rotate (the home screen).  I already double clicked home button and scrolled over, the circle arrow does NOT have the lock inside it.  I went thru all the settings and can find nothing to try and fix this.  Do I need to send the phone back?  Is it broken?  I just got it yesterday.  It has not been damaged in any way.  Please help.

    |rob| wrote:
    taramdunn wrote:
    My screen refuses to rotate (the home screen).
    The home screen doesn't rotate to landscape mode.  Only apps do.
    Good eye Rob, I didn't even catch that.

  • "Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect? URL: /includes/javascript/xajax_js/xajax.js". other posters with a xajax error on this board got the response to go look for developer resources. (i'm not a developer)

    I'm on a mac running 10.6.8, was using Firefox 6.02 when the problem started, i performed a clean install of 7.01, installed the latest Flashplayer, and reinstalled java (the 10.6.5 update file from apple's site).
    I seem able to load video at youtube.com, and was able to load web-based irc chatrooms at ircchat.tv. however, at jamplay.com a paid member site, all of the lessons are flash video, and there's a live video feed chat room that is also flash based, and I am not able to view this content. the video content pops up the error message "Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?
    URL: /includes/javascript/xajax_js/xajax.js" and the clicking on the "launch chatroom" button does exactly nothing.
    I have contacted the jamplay site team but their recommendations are the steps I have already taken, mentioned above, that did not resolve the issue.
    some links to content on their site visible without being a member:
    http://www.jamplay.com/
    this one has a flash interface that, if things were working, would have a video in the center and members and staff talking abouth that area of the site when you click on one of the title buttons. Now that I am having this problem, nothing is clickable and there's no indication that there should be a video in the center. The error message regarding xajax does not come up at all.
    http://www.jamplay.com/guitar-lessons/beginners/1/527-16-circle-of-fifths
    same thing. video content is missing, xajax error does not appear.
    http://www.jamplay.com/live
    when I load these all content except the video loads on the page. this page does not give me the error at all, just does not load the video
    I can't seem to recreate the actual error without being logged in as a member of the site.
    The apple support team gave me a one-time free suppport ticket to troubleshoot an ethernet issue I was having. Unfortunately, the databases I removed were not deemed either by apple or me to be noteworthy or necessary to retain (all of them were for software I not longer have or use). I don't know which plist file might have been the one I need now. I did reinstall the java and flash items. The only other item that I think it might be is a set of belkin router software that I uninstalled because i'm not using any belkin hardware anymore.
    If someone has any kind of idea I would be most appreciative.

    That's a comment in the file. It has no effect at all.

  • Is there a way to run javascript in the url in FF6?

    With the introduction of scratchpad to FF6 the javascript in the url is filtered out and will not execute.
    The only way i have been able to run js scripts is to use the scratchpad even if it's a one line thing that i need.
    I went into about:config and typed javascript into the filter then changed the browser.urlbar.filter.javascript configuration from true to false, nothing changed.

    Running javascript: in the urlbar is no longer supported in version 6 for security reasons. Users were installing malware. Please use the scratchpad.

  • Most pages are loading without formatting and in addition I am getting the following error message on certain sites. Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect? URL: /xajax_js/xajax.js

    I'm using Firefox v6.0 on windoze XP sp3. I had no problems until after using webroots window washer and updating Firefox. I don't know which of those things (if either) may be the cause of the problem. The URL of the worst affected site (the one that spawns the error message is pasted below. But other sites are also loading so that they look like they are unformatted. Any suggestions most welcome.

    Since Chrome is working, then there's something going wrong with your IE and Firefox installs of Flash Player.  Could you tell me what files you have in the C:\Windows\System32\Macromed\Flash folder?
    You might want to give a clean install a shot:
    How do I do a clean install of Flash Player?
    Then for IE issues, follow it up with the steps in:
    Enabling Flash Player in Internet Explorer 9

  • URL Target - conditions on javascript:confirmDelete()

    Is it possible to change the text of the confirmDelete() dialog that pops up when the user clicks 'Submit' button?
    Before submitting the form the user will either click BUTTON A and continue completing the fom in one way, OR
    click BUTTON B and complete the form differently.
    Both buttons rely on their own requests to do what they need to do
    BUTTON A = :REQUEST = 'SUBMIT'
    BUTTON B = :REQUEST = 'DISPLAY'
    When the user hits 'Submit' at the end, I want the message to do one of the following:
    javascript:confirmDelete('You're updating with BUTTON A', 'REQUEST');OR
    javascript:confirmDelete('You're updating with  BUTTON B', 'REQUEST');Is somethign like this possible? As always, TIA.

    Okay, so I'm not sure what my arguments should be. Here's what I've got:
    Buttons
    (copied from page definition)
    5 Revision Redirect to page 51 - Button Request = 'SUBMIT'
    10 Version Redirect to page 51 Button Request = 'DISPLAY'
    Items
    :P51_REVISION
    :P51_VERSION
    1. User clicks REVISION and :P51_REVISION item is incremented (i.e., F-100 to F-100A) OR User clicks VERSION and :P51_VERSION item is incremented (i.e., F-100A to F-100Av1)
    2. :P51_VERSION remains null OR :P51_REVISION remains null
    3. User completes updates to rest of form
    4. User hits SUBMIT button
    5. confirmDelete message pops up
    _1. Based on the above, I'm not understanding what my arguments (someValue, someValue2) should be_
    function determineButton(somevalue1,somevalue2)
      if ($v(somevalue)==$v(somevalue2)) //or whatever your condition needs to be
        javascript:confirmDelete("You're updating with BUTTON A", 'BUTTON_A');
      else
        javascript:confirmDelete("You're updating with  BUTTON B", 'BUTTON_B');
    }_2. Do :P1_SOMEITEM and :P1_SOMEOTHERITEM correspond to :P51_REVISION and :P51_VERSION?_
    In your URL that executes:
    javascript:determineButton("P1_SOMEITEM","P1_SOMEOTHERITEM");
    [/code]
    Edited by: userRRRYB on Oct 21, 2010 7:53 AM
    Edited by: userRRRYB on Oct 21, 2010 7:53 AM
    Edited by: userRRRYB on Oct 21, 2010 7:54 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • HOWTO:  Changing the URL and reloading the dataset

    Sometimes, you will need to change the url of your dataset
    and reload the dataset. This is quite easy to do with changing a
    variable and calling a method. Below is the code you would use. I
    use it to page through a set of data which only comes back in 10
    row increments and we do not know the recordcount of. (Yippee,
    Oracle E1). Anyway, here's the code....
    <script type="text/javascript" language="javascript">
    rowCount = 0;
    dsPeople = new
    Spry.Data.XMLDataSet("/spry/?event=peopleSearch&srchRowStart="
    + rowCount,"/orders/row", { useCache: false });
    function changeRowCount()
    rowCount = rowCount+10;
    var spryURL = "/spry/?event=peopleSearch&srchRowStart="
    + rowCount;
    dsPeople.url = spryURL;
    dsPeople.loadData();
    </script>
    <div spry:region="dsPeople">
    <div spry:state="loading"><img
    src="/assets/images/ajax-loader.gif"/></div>
    <div spry:state="error">Error Loading
    Data...</div>
    <div spry:state="ready">
    <div spry:repeat="dsPeople">
    <span spry:content="{dsPeople::NAME}"></span>
    </div>
    <a href="javascript:changeRowCount()"><span
    spry:content="Next 10 Records"></span></b>
    </div>
    </div>

    Enabling SSL for Central Administration is a good idea. Making it so it is only accessible using an IP address doesn't make it any more secure. This is security through obscurity and anyone dedicated enough to attacking Central Administration will find the
    site whether it's an IP address or named.
    For what it's worth an attacker is going to try scanning IP ranges long before they try looking at DNS. And, because of the way SharePoint works if the site is accessible by its IP address and not a specific hostname, anyone who knows the IP address and
    the SSL port (443) can connect. If you have a hostname it won't be immediately accessible.
    Some other thoughts: When you rely just on the IP address, what happens if you want to move Central Administration to another server in the farm, or you want to provide load balancing and have multiple servers hosting Central Administration? What happens
    when the server running Central Administration dies so you create a new Central Administration site on a server with a different IP address? How will you communicate this URL change to all of your administrators?
    Jason Warren
    @jaspnwarren
    jasonwarren.ca
    habaneroconsulting.com/Insights
    Sorry,
    I wasn't clear in my OP.  The IP would be tied to a DN.  So you would go https://abc123.com and it would ask for authentication.  That URL would be tied to a separate IP on the network card of that server.  The IP address association
    is done through IIS.

Maybe you are looking for

  • Someone asked whether ATV was worth it or not - here are my thoughts

    Whether or not ATV is a good product probably depends on where youlive. Im writing from Adelaide Australia and ATV is a disappointmentfor me right now. The best download speed my ISP can provide - which Ithink is the standard at moment in this part o

  • Can't get my dropdown menu buttons to link to another scene.

    I can't get my dropdown menu buttons to link to other scenes within the same Flash file.  The buttons are unresponsive during playback – as if no code were attached to it.  Here's what I have as my AS2 code on the dropped button that is supposed to l

  • N97 contacts don't show up

    Okay, to cut a long story short... I tried to install an app on my phone and the installation failed. After that I started to get a "system error" message every few minutes on my phone. I decided to do a soft reset on the phone. This sorted out the e

  • Why is my keyboard shortcut not working?

    Indesign keyboard shortcut for CUT (command+x) is not working. I'm on a Mac running OS 10.9.5. I need that puppy!

  • Can not connect to itunes store even though i have wifi connection

    my ipad 2 used to be registered to my husbands itunes store but now he has left us and i am trying to sync it to my itunes store. I have plugged ipad to itunes and synced it. Apple ID on ipad is showing as mine but when i try to download apps, it say