JavaScript to set default value on SharePoint form field

I found the below script, placed it in but no change...  is there any obvious issue?

<script src=”https://code.jquery.com/jquery-1.11.0.min.js”</script>
<script type=”text/javascript”>

$(document).ready(function() {

$(“select[Title=’PursuitType’]”).val(‘CLIN 6AG’);

});

</script>
Matt PinkstonEnterprise ArchitectAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Works for me - so either you don't have a select with that title or there is some error on your page.

1. Check your console for errors (F12)
2. Check that you have a select with Title PursuitType

This sample demonstrates the code works

Aside: why are you using a title as a selector? Surely the <select> has at least a name or an id - which would be more logical?
0
Matt PinkstonEnterprise ArchitectAuthor Commented:
Thanks for the reply

<SharePoint:FormField runat="server" id="ff2x{$Pos}" ControlMode="New" FieldName="PursuitType" __designer:bind="{ddwrt:DataBind('i',concat('ff2x',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@PursuitType')}" />

When I try to add title= it says that is not valid
0
Julian HansenCommented:
Ok but I ask again why are you trying to reference the select by title?

Why not ID or Class?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Matt PinkstonEnterprise ArchitectAuthor Commented:
the JavaScript I found asks for title????

$(“select[Title=’PursuitType’]”).val(‘CLIN 6AG’);
0
Julian HansenCommented:
the JavaScript I found asks for title????
The code you posted has an ID so you can use an id

$("#ff2x{$Pos}").val('CLIN 6AG'); 

Open in new window


If there is only one select on the page then

$("select").val('CLIN 6AG'); 

Open in new window


Failing that post the rendered HTML for the page and let's see what SharePoint spits out.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Matt PinkstonEnterprise ArchitectAuthor Commented:
Thanks....
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.