Passing value from URL to EDIT Form
Deronda created the topic: Passing value from URL to EDIT Form
Hi! I've followed several other posts regarding passing parameters...but I'm missing something.
I have a URL such as:
dev.website.org/surname-edit/?snid=1
I've created an UPDATE form where I want all the fields populated based on the SNID in the URL. The SNID I want hidden. Typically, I would use a php statement in the WHERE clause, but that's not working. WHERE snid= '<?php $_GET[snid] ?>'
HELP! I've been working on this all day, and I'm brain dead now. I know it has to be something simple.
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Anoush replied the topic: Passing value from URL to EDIT Form
Hello Deronda,
Thanks for getting to us!
So you want that after submitting the form the information (which is sent to the administrator) also included the page url, is it ?
Thanks and have a nice day!
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Deronda replied the topic: Passing value from URL to EDIT Form
Hi! I have another page that has a list of surnames. In that report, contains a hyperlink with the parameter. So, I'd want the information pulled when the form is first opened.
SELECT CONCAT('<a href=surname-edit/?snid=', snid,' >', 'Edit','</a>') as 'EDIT', surname as 'Surname' from website.tgs_surnames ORDER BY surname
So, the person views this report first, clicks on the EDIT link then will open this new FORM to edit/update the information. Then I'll have them return back to the report with the updated information...hopefully.
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Deronda replied the topic: Passing value from URL to EDIT Form
This is the code I'm trying out, but I'm thinking there's something that needs to be added in the field value? in the SQL Mapping, I've tried PHP code, simple GET statement and just linking to the SQL field {18}. But nothing populates in the form...Value is always "".
function before_load() {
function getParameterByName(name, url) {
if (!url) {
url = window.location.href;
}
name = name.replace(/[[]]/g, "$&");
var regex = new RegExp("[?&]" + name + "(=([^]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/+/g, " "));
}
jQuery("#wdform_18_element10").val(getParameterByName("snid"));
jQuery("#wdform_18_element10").attr("class", "input_active");
window.onload=function(){
document.getElementById('snid').value = '2';
}
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Anoush replied the topic: Passing value from URL to EDIT Form
Hello Deronda,
Could you please also share the link where you have published the form?
Thanks!
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Deronda replied the topic: Passing value from URL to EDIT Form
Sure! I can see that the form recognizes the URL, but now trying to figure out how to populate the fields based on that record. Example: snid=2.
This is the first page where folks will click on edit to what I hope will edit content.
dev.tulsagenealogy.org/surname-testmemberlist
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Anoush replied the topic: Passing value from URL to EDIT Form
Dear Deronda,
You have done all correctly. Only please instead of this return decodeURIComponent(results[2].replace(/+/g, " ")); add this one return decodeURIComponent(results[2].replace('/+/g', " "));
Thanks and have a great day!
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Deronda replied the topic: Passing value from URL to EDIT Form
Thank you!!!!! That piece of the puzzle worked.
Please Log in or Create an account to join the conversation.
6 years 6 months ago
Anoush replied the topic: Passing value from URL to EDIT Form
Dear Deronda,
Great it is very nice to hear!
Is there any chance you could share your experience on review page
here.
Thanks and have a wonderful day!
Please Log in or Create an account to join the conversation.
6 years 6 months ago