jbooker wrote:
Russ thanks for this. Havn't tried it yet, but for those who want to do this completely client-side (no SPD), you can add the link using script like so:
$("input[title='ITVendor']").parents("td.ms-formbody").append("<a onclick='javascript:AddVendor()'>Add Vendor</a>");
Where 'ITVendor' is the internal name of the lookup column.
Josh
I appreciate your help. I tried this and the link doesnt show up. if you have time please review and tell me whats wrong thanks:
<script src="/_layouts/1033/jquery-1.7.1.js" type="text/javascript"> $(document).ready(function(){ $("input[title='Columns (fields)']").parents("td.ms-formbody").append("<a onclick='javascript:AddColumn()'>Add New Columns(fields)</a>"); }); // this function gets called when the user clicks the "Add Column Link" function AddColumn(){ //debugger; var siteUrl=SP.ClientContext.get_current().get_url(); var options = SP.UI.$create_DialogOptions(); options.title = "Add Column"; options.url = siteUrl+"/Lists/fields/NewForm.aspx"; options.dialogReturnValueCallback=ColumnAdded; SP.UI.ModalDialog.showModalDialog(options); } function ColumsAdded(value,returnValue){ if (value == '1') { this.statusId = SP.UI .Status .addStatus("Column Added", "Your Column has been sucessfully added.", true); SP.UI.Status.setStatusPriColor(this.statusId, "Green"); } if (value == '0') { this.statusId = SP.UI .Status .addStatus("Column not added", "Your Column was <b>not</b> added. Please try again.", true); SP.UI.Status.setStatusPriColor(this.statusId, "Green"); } setTimeout(RemoveStatus, 6000); debugger; // now refresh the droopdown list of Columns-- if the Column List has leess than 20 Items, the dropdown list is rendered as a simple select and we use field "ColumnDropDown", // otherwise, it's rendered as a textbox and a hiddentextbox (with some fancy behaviors) and we use fields ColumnInput and hiddenColumnInput (Column input holds the // display value and HiddenColumnInput holsd the ID; var ColumnDropDown=$("select[Title=Columns (fields)]")[0]; if (ColumnDropDown == null){ var ColumnInput = $("input[title='Columns (fields)']")[0]; var hiddenColumnInputFieldName = $("input[title='Columns (fields)']").attr("optHid"); var hiddenColumnInput = $("input[id='"+hiddenColumnInputFieldName +"']")[0]; } var siteUrl=SP.ClientContext.get_current().get_url(); $.ajax({ url: siteUrl+ "/_vti_bin/listdata.svc/fields?$orderby=Title&$select=Title,Id", dataType: 'json', async: false, success: function (data) { //debugger; var maxid=0; var choices=""; if (ColumnDropDown == null){ // , there were more than 20 items and I have to hack the textboxes/ $.each(data.d.results,function(){ if (this.Id > maxid){ // save the maximum ID value -- this is the one the user just added maxid=this.Id; ColumnInput.value=this.Title; hiddenColumnInput.value=this.Id; } if (choices==""){ choices=this.Title; } else { choices=choices+"|"+this.Title; } }); } else { // if there are less than 20 Columns ColumnDropDown is used //note that the page using this script must have EnableEventValidation="false" because we are dynamically adding elements to the field Dropdown list, // I don't wan to do this globally, so I'm commenting out this code return; ColumnDropDown.options.length=0; $.each(data.d.results,function(){ debugger; if (this.Id > maxid){ // save the maximum ID value -- this is the one the user just added maxid=this.Id; } ColumnDropDown.options.add(new Option(this.Title,this.Id)); }); ColumnDropDown.value=maxid; // set the dropdowns value to the item that was just added. } }, error:function (xhr, ajaxOptions, thrownError){ alert(xhr.status + "returned when adding Column"); alert(thrownError); } }); } </script>