none
Populate Query String to Title Field of NEwform.aspx

    Question

  • I have this URL http://servername/site/Lists/ListsName/NewForm.aspx?Title=Item Title

    I need to populate the value of the Title in the URL which is "Item Title" in the Title textbox of NewForm.aspx

    How can i achieve this. Im planning of using sharepoint designer and write a c# script in page load.


    cal_bonjovi

    Friday, February 17, 2012 6:22 AM

Answers

  • Hi cal_bonjovi,

    From your descrition, you need to add the Title parameter from URL to the Title textbox in the NewForm.aspx, we can use JavaScript to do this follow this step:

    1. Type this URL in IE. http://servername/site/Lists/ListsName/NewForm.aspx?pageview=shared&toolpaneview=2
    2. Add Content Editor Web Part below the New Item Form Web Part.
    3. Add following script into the source editor of the Content Editor Web Part.
    <script type="text/javascript">
    var URL= String(window.location.href);
    //URL.substring(URL.indexOf("=")+1,URL.length)
    
    document.getElementById("ctl00_m_g_18a5cb69_3e65_42b8_810f_50f8e59b8910_ctl00_ctl04_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField").value=URL.substring(URL.indexOf("=")+1,URL.length);
    
    </script>

    Note: Please replace the Element ID with yours, and we can use IE F12 Developer tools to get the textbox ID of Title field.

     

    Thanks & Regards,
    Emir Liu
    TechNet Subscriber Support in forum
    If you have any feedback on our support, please contact
     tnmff@microsoft.com.


    Emir Liu

    TechNet Community Support




    Monday, February 20, 2012 7:34 AM