Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0
Sign in to follow this  
acornwell

Can a text field be pre-filled based on a URL parameter?

Question

I'm using the Wells template and would like users to be able to click a link in a photo caption and be taken to a form where they can inquire about the image and the image number is pre-filled into a text field so the user doesn't have to remember what number to fill in there. In other words, a link looking something like this:

http://xyz.com/contact?img=20150314_0048

The link goes to the "contact" page with a form where a text field for "img" is pre-filled with "20150314_0048".

When I do a view source of the contact page, I see the text field has an ID of "text-yui-(string of numbers)-field" which is perhaps what I would need to reference in place of "img" in the URL link on each image? I tried that and nothing was pre-filled. Any suggestions?

Edited by Jeng
retag

Share this post


Link to post

5 answers to this question

Recommended Posts

  • 1

you can do it this


<input type="text" name="uniquecode" id="uniquecode" style="width: 350px;" class="input" value="" placeholder="Copy-Paste your Code"/>

<script type="text/javascript">

window.onload=function(){ 

function querySt(ji) {

hu = window.location.search.substring(1); 
gy = hu.split("&");

for (i=0;i<gy.length;i++) { 
ft = gy[i].split("="); 
if (ft[0] == ji) { 
return ft[1]; 
} 
} 
} 
var uc = querySt("uc");


if( uc==null){ 
}else{ 
document.getElementById('uniquecode').value = uc; 
} 
} 
</script>

then I can input an URL such as:

http://www.xyz.com/page?uc=sometextformyform

This work but I am looking to do that with squarespace product / popup forms if anyone knows?

Share this post


Link to post
  • 0

Not without the developer platform, and not without a pretty advanced understanding of json/javascript...and really you would need access to the database to define this and that. Which is something I have yet to figure out how to do! I don't think the developer platform opens up access enough to the data needed. I could be wrong though!

Also anytime you see a "yui" and a string of numbers, you need to know those change dynamically on each page load.

Edited by SquarespaceGuru

I run the Squarespace Guru blog (www.sqsp.guru) and host the Squarespace Guru podcast.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in to follow this  

×
×
  • Create New...