Matt Pinkston
asked on
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=’PursuitTy pe’]”).val (‘CLIN 6AG’);
});
</script>
<script src=”https://code.jquery.com/jquery-1.11.0.min.js”</script>
<script type=”text/javascript”>
$(document).ready(function
$(“select[Title=’PursuitTy
});
</script>
ASKER
Thanks for the reply
<SharePoint:FormField runat="server" id="ff2x{$Pos}" ControlMode="New" FieldName="PursuitType" __designer:bind="{ddwrt:Da taBind('i' ,concat('f f2x',$Pos) ,'Value',' ValueChang ed','ID',d dwrt:Escap eDelims(st ring(@ID)) ,'@Pursuit Type')}" />
When I try to add title= it says that is not valid
<SharePoint:FormField runat="server" id="ff2x{$Pos}" ControlMode="New" FieldName="PursuitType" __designer:bind="{ddwrt:Da
When I try to add title= it says that is not valid
Ok but I ask again why are you trying to reference the select by title?
Why not ID or Class?
Why not ID or Class?
ASKER
the JavaScript I found asks for title????
$(“select[Title=’PursuitType’]”).val(‘CLI N 6AG’);
$(“select[Title=’PursuitType’]”).val(‘CLI
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks....
You are welcome.
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?