1

So I'm not all that good with JavaScript and figured that this would be the only way it could be done, if there is another way great, I am trying to make a rota and have it so I can save the selected person upon selecting them without having to go and save it all manually over and over or using excel (the load time for it is a bit slow and the point of me doing this is to make it more "modern") I've got a list and have the selected via HTML code in SharePoint designer (see below) but it won't save the different selected's when changing which is what I want it to do.

<select id="dutyTech" size="1">
            <option value="0" selected="selected">User 1</option>
            <option value="1">User 2</option>
            <option value="2">User 3</option>
            <option value="3">User 4</option>
            </select>

Anyone have any idea's that would be much appreciated and apologies if I don't immediately understand if it has coding, HTML is the one I know.

(will put the full code in below in case it is required):

    </div></div></td></tr><tr style="vertical-align&#58;top;"><td style="width&#58;49.95%;"><div class="ms-rte-layoutszone-outer" style="width&#58;100%;"><div class="ms-rte-layoutszone-inner"><p></p><p>
        ​</p><p>​<br></p><br><table cellspacing="0" class="ms-rteTable-7" style="width&#58;85%;"><tbody><tr class="ms-rteTableHeaderRow-7"><th class="ms-rteTableHeaderEvenCol-7" rowspan="1" colspan="1" style="width&#58;111px;"><p><span class="ms-rteFontSize-3"><strong>
            Day​​​​​​</strong><br></span></p></th><th class="ms-rteTableHeaderOddCol-7" rowspan="1" colspan="1" style="width&#58;33.3333%;"><p><span class="ms-rteFontSize-3"><strong>
            Duty Tech​</strong><br></span></p></th><th class="ms-rteTableHeaderEvenCol-7" rowspan="1" colspan="1" style="width&#58;33.3333%;"><p><span class="ms-rteFontSize-3"><strong>
            ​Back-Up​</strong></span><br></p></th></tr><tr class="ms-rteTableOddRow-7"><td class="ms-rteTableEvenCol-7" style="width&#58;111px;"><span class="ms-rteStyle-Emphasis">
                ​<strong>Monday​</strong><br></span></td><td class="ms-rteTableOddCol-7"><select id="dutyTech" size="1">
            <option value="0" selected="selected">User 1</option>
            <option value="1">User 2</option>
            <option value="2">User 3</option>
            <option value="3">User 4</option>
            </select><br></td><td class="ms-rteTableEvenCol-7" rowspan="1" colspan="1">
            <select id="dutyTech" size="1">
                <option value="0">User 1</option>
                <option value="1" selected="selected">User 2</option>
                <option value="2">User 3</option>
                <option value="3">User 4</option>
            </select>
            ​</td></tr><tr class="ms-rteTableEvenRow-7"><td class="ms-rteTableEvenCol-7" style="width&#58;111px;"><span class="ms-rteStyle-Emphasis">
                ​<strong>Tuesday</strong><br></span></td><td class="ms-rteTableOddCol-7"><select id="dutyTech" size="1">
            <option value="0" selected="selected">User 1</option>
            <option value="1">User 2</option>
            <option value="2">User 3</option>
            <option value="3">User 4</option>
            </select>​</td><td class="ms-rteTableEvenCol-7" rowspan="1" colspan="1">
            <select id="dutyTech" size="1">
                <option value="0">User 1</option>
                <option value="1">User 2</option>
                <option value="2" selected="selected">User 3</option>
                <option value="3">User 4</option>
            </select>

                ​</td></tr><tr class="ms-rteTableOddRow-7"><td class="ms-rteTableEvenCol-7" style="width&#58;111px;"><span class="ms-rteStyle-Emphasis">
                ​<strong>Wednesday</strong><br></span></td><td class="ms-rteTableOddCol-7">
                <select id="dutyTech" size="1">
                <option value="0" selected="selected">User 1</option>
                <option value="1">User 2</option>
                <option value="2">User 3</option>
                <option value="3">User 4</option>
            </select>

                ​</td><td class="ms-rteTableEvenCol-7" rowspan="1" colspan="1">
                <select id="dutyTech" size="1">
                <option value="0">User 1</option>
                <option value="1">User 2</option>
                <option value="2">User 3</option>
                <option value="3" selected="selected">User 4</option>
            </select>
                ​</td></tr><tr class="ms-rteTableEvenRow-7"><td class="ms-rteTableEvenCol-7" style="width&#58;111px;"><span class="ms-rteStyle-Emphasis">
                ​<strong>Thursday</strong><br></span></td><td class="ms-rteTableOddCol-7">
                <select id="dutyTech" size="1">
                <option value="0" selected="selected">User 1</option>
                <option value="1">User 2</option>
                <option value="2">User 3</option>
                <option value="3">User 4</option>
            </select>

                ​</td><td class="ms-rteTableEvenCol-7" rowspan="1" colspan="1">
                <select id="dutyTech" size="1">
                <option value="0">User 1</option>
                <option value="1">User 2</option>
                <option value="2" selected="selected">User 3</option>
                <option value="3">User 4</option>
            </select>
                ​</td></tr><tr class="ms-rteTableOddRow-7"><td class="ms-rteTableEvenCol-7" style="width&#58;111px;"><span class="ms-rteStyle-Emphasis">
                ​</span><strong class="ms-rteStyle-Emphasis">Friday</strong><br></td><td class="ms-rteTableOddCol-7">
                <select id="dutyTech" size="1">
                <option value="0">User 1</option>
                <option value="1">User 2</option>
                <option value="2">User 3</option>
                <option value="3" selected="selected">User 4</option>
            </select>

                ​</td><td class="ms-rteTableEvenCol-7" rowspan="1" colspan="1">
                <select id="dutyTech" size="1">
                <option value="0">User 1</option>
                <option value="1" selected="selected">User 2</option>
                <option value="2">User 3</option>
                <option value="3">User 4</option>
            </select>
                ​</td></tr><tr class="ms-rteTableEvenRow-7"><td class="ms-rteTableEvenCol-7" colspan="3">
                ​​<br></td></tr><tr class="ms-rteTableOddRow-7"><td class="ms-rteTableEvenCol-7" style="width&#58;111px;"><span class="ms-rteStyle-Emphasis">
                ​</span><strong class="ms-rteStyle-Emphasis">​Change 
                Approver</strong><br></td><td class="ms-rteTableOddCol-7" colspan="2"><div style="text-align&#58;center;"><select id="dutyTech" size="1">
                <option value="0">User 1</option>
                <option value="1">User 2</option>
                <option value="2" selected="selected">User 3</option>
                <option value="3">User 4</option>
                <option value="4">User 5</option>
                <option value="5">User 6</option>
                </select><br></div></td></tr><tr><td rowspan="1">​​<span class="ms-rteStyle-Emphasis"><strong>On 
                Call</strong></span><br></td><td colspan="2" rowspan="1" style="text-align&#58;center;"><select id="dutyTech" size="1">
                <option value="0">User 1</option>
                <option value="1">User 2</option>
                <option value="2">User 3</option>
                <option value="3" selected="selected">User 4</option>

​​

​​

edit: picture of design Design of Rota

0

Firstly there's a couple of things, this is a default New/EditForm.aspx right?

I've run across similar issues with using the 'selected' attribute in an Option. In JS there is a property for a select called .selectedIndex and is what is actually updated when changing a select element.

I believe SharePoint has several fallbacks for checking this value but seems to always take an option with a selected attribute as the value first.

I'd suggest try removing the 'selected' attribute from all of the options in the HTML. This way SharePoint will use the correct selected value for the select. I think select elements load up with the first option selected so the 'selected' for the first option is redundant anyway.

  • So the selected value is now always defaulted to User 1 after that change which is fine that it works at defaulting a selected anyway, however what i want it to do is save the selected to the option i pick for example i would want User 3 instead of User 1 to be the option selected on the next time i load the webpage but without having to go through the HTML to change the selected options. (hope that makes sense) edit: I've included a picture in the original post of the design of the box (blacked out the names as they are my colleagues names and numbers where i just use User 1-4 as examples) – Luke Easton Aug 15 '18 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.