I have an Umbraco V4 website and on the site I have a vacancies page, the vacancies page list the vacancies then after each one has a link to the vacancy application form which is a form created using doc2form. One of the fields in the form is "Job you are applying for". I would like this to be automatically filled in depending on what job they try to apply for, I have added the relevant querystring to the link as follows:
<a href="{umbraco.library:NiceUrl(1220)}?id={@nodeName}">Click here to apply for this vacancy</a>
But how can I make this populate the doc2form field, is it possible? Or would I have to create some kind of custom form? (hopefully not because I am not a developer!)
Thanks for the response, is your way not a good way to do it then? I'm a bit confused as to how I would use your method to get it to work with what I have already got or would you not recommend doing it your way? So far I have the following XSLT:
<xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']"> <xsl:sort select="@createDate" order="descending" /> <div class="vacancy-text"> <h2><xsl:value-of select="@nodeName"/></h2> <xsl:value-of select="data [@alias = 'jobdescription']" disable-output-escaping="yes"/> <a href="{umbraco.library:NiceUrl(1220)}?id={@nodeName}">Click here to apply for this vacancy</a> </div> </xsl:for-each>
I don't like relying on javascript for things like this, but it will work. You'd just need to adjust my posted code to search for 'id' instead of 'property' as it does now, then you can prefill the value with javascript. Doc2Form gives each list item that surrounds the input fields a class of
documentProperty_li
so you can target the specific inputs with javascript
Thanks for the response, sorry I'm not really up on javascript. I think I understand second part, on my doc2form page I have some javascript code like this:
$('.jobtitle_li input').val(jobTitle);
But I am unsure as to where the XSLT you have shown goes, is it on my my vacancy list page and how does it add the right javascript parameter to the correct link?
Ok, so the code in my post above goes in a macro placed on the same page as your doc2form macro. This ensures that when people visit the doc2form page the querystring is captured and passed to your javascript variable. That's the first part, and is how it knows the id to pass to the js variable.
You can use the above javascript in an external script or in on-page, it's up to you. It's jquery so will need to be placed inside a document ready call with the jquery library installed. If you're not already using jquery you may want to do this another way, as it's 50kb of extra code just to do this. You could do the second part (giving the input field the value of your new variable) in any js library, or with straight javascript if you prefer.
Does this help? I may have just confused things more, but you're very near to getting this working!
Excellent I've now got it working, thanks once again Dan. I was just a little confused as to what went where. I thought the XSLT above was to replace what I had (the querystring bit) but it was to run in addition to it. As I said I don't really know javascript so I was struggling to understand what your code was trying to do but now it is all working I can see how it does work (if that makes sense!).
Add querystring value into doc2form field
Hi,
I have an Umbraco V4 website and on the site I have a vacancies page, the vacancies page list the vacancies then after each one has a link to the vacancy application form which is a form created using doc2form. One of the fields in the form is "Job you are applying for". I would like this to be automatically filled in depending on what job they try to apply for, I have added the relevant querystring to the link as follows:
But how can I make this populate the doc2form field, is it possible? Or would I have to create some kind of custom form? (hopefully not because I am not a developer!)
I'd love to hear a good way to do this, as in the past I've used jquery/javascript like this:
Then you've got a javascript variable with your querystring value that you can pass to doc2form like the following
Dan
Hi Dan,
Thanks for the response, is your way not a good way to do it then? I'm a bit confused as to how I would use your method to get it to work with what I have already got or would you not recommend doing it your way? So far I have the following XSLT:
I don't like relying on javascript for things like this, but it will work. You'd just need to adjust my posted code to search for 'id' instead of 'property' as it does now, then you can prefill the value with javascript. Doc2Form gives each list item that surrounds the input fields a class of
documentProperty_li
so you can target the specific inputs with javascript
Hi Dan,
Thanks for the response, sorry I'm not really up on javascript. I think I understand second part, on my doc2form page I have some javascript code like this:
$('.jobtitle_li input').val(jobTitle);
But I am unsure as to where the XSLT you have shown goes, is it on my my vacancy list page and how does it add the right javascript parameter to the correct link?
Ok, so the code in my post above goes in a macro placed on the same page as your doc2form macro. This ensures that when people visit the doc2form page the querystring is captured and passed to your javascript variable. That's the first part, and is how it knows the id to pass to the js variable.
You can use the above javascript in an external script or in on-page, it's up to you. It's jquery so will need to be placed inside a document ready call with the jquery library installed. If you're not already using jquery you may want to do this another way, as it's 50kb of extra code just to do this. You could do the second part (giving the input field the value of your new variable) in any js library, or with straight javascript if you prefer.
Does this help? I may have just confused things more, but you're very near to getting this working!
Dan
Excellent I've now got it working, thanks once again Dan. I was just a little confused as to what went where. I thought the XSLT above was to replace what I had (the querystring bit) but it was to run in addition to it. As I said I don't really know javascript so I was struggling to understand what your code was trying to do but now it is all working I can see how it does work (if that makes sense!).
is working on a reply...