Hi,
thanks for the details information.
Actually that is quite a specific use case and not possible with Visforms out of the box, but I think it's possible to realize.
If I had to extend Visforms for a client with your feature I would not try to interfere with the core code of Visforms (php) but use Javascript, because there would be quite a lot of php code to be changed and you would have to maintain those changes individually with every update of Visforms.
I woud try to place the Javascript inside the index.php of the template and not in Visforms files to prevent it from being overridden by updates of Visforms.
You can add any parameters to the Url that calls the form. The parameters are not cut away our such things. So the Url you send to your clients would look something like
yourJoomlaWebsite/index.php?option=com_visforms&id=1&field1=450
where id is the form's id and field1 is your price field
Please do not link the form to a menu item, because this would cause the SEO router to convert option=com_visforms&id=1 into a SEO url.
The input of every form field (which is represented by an HTML input) has a specific id which is composed from the string "field" and the field's id (which you can find in the id column of the fields view in backend). (So This will not work for radios or selects but I think that is of no concern to you).
Essentially you have to write some Javascript code to get the Url parameter. If you are on Joomla! 3 you could preferrably use jQuery which is already part of the Joomla! core but must of course be included in the template. If you are on Joomla! 2.5 using jQuery may cause problems so you could use just Javascript without a framework like jQuery.
The following Javascript function should do the trick without jQuery but of course I have not tested it on many browsers
Code:
function getArg(name) {
var args = new Object();
var query = location.search.substring(1);
var pairs = query.split("&");
number_of_arguments = pairs.length;
for (var i=0; i<number_of_arguments; i++){
var pos = pairs[i].indexOf('=');
if (pos == -1){
continue;
}
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
args[argname] = unescape(value);
}
if (args[name]){
return args[name];
} else {
return null;
}
}
You can use some code similar to the following one, to set the parameter value from url as input value
Code:
var field1value = getArg('field1');
var field1 = document.getElementById("field1");
field1.value = field1value;
Of course you have to make sure, that you only run the code when you display the form and that the field is available and so on, but you can use the getArg() function to check if the url contains the option=com_visforms and the id=1
I just outlined the principles of the solution here, not a fully developed and tested solution. I hope you have some coding skills and can transform the sketch into working code following my instructions.
If you have further questions, feel free to ask.
Regards,
Aicha