Home › Forums › Quform WordPress › Passing a URL Variable to Form on Another Page
- This topic has 8 replies, 3 voices, and was last updated 10 years, 3 months ago by
Ally.
- AuthorPosts
- November 21, 2013 at 7:22 pm #7514
lawrencepepper
ParticipantI have a table in which the first column of each rows lists an ID that when clicked passes that ID to a new url as so:
<code>
<a href="http://test.gen-techno.com/update-hours/change-form?id=' . $row['id'] . '">' . $row['id'] . '</a></code>
I on that next page when the ID is clicked I need to query the database and grab the data for that ID and use it to populate the fields in a form.
I can not figure out how to do this. I know how to do this with the functions.php page but going that route does not allow me to send it the ID that is needed to grab the data.
Any ideas?
L
November 22, 2013 at 9:56 am #7524Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
November 22, 2013 at 2:14 pm #7528lawrencepepper
ParticipantWhat I have is a page that displays a table which was populated by a query from my database.
The first column in the table holds the unique ID of each row which is a clickable link which will pass that unique ID variable to the URL that the link goes to.
When the person clicks that ID it takes them to a new page in which I then need a form that will auto fill from a query to the database based on the unique ID that was passed when they clicked the link.
SO how do I get the unique ID that they click and pass to the function listed above on the functions.php file so that it knows what record to grab.
?
- This reply was modified 11 years, 5 months ago by
lawrencepepper.
November 22, 2013 at 2:38 pm #7530lawrencepepper
ParticipantOK,
I understand now, I used your example above and it works great!
One question though,
The date field does not populate correctly.
How do I pass a date so that the date picker in the form accurately show the date from the database.
L
November 26, 2013 at 10:25 am #7576Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
January 4, 2015 at 12:21 am #13507Joe Dostie
ParticipantHi,
I have a referring URL with a value in it but its a single item so it looks like this:
http://69.195.124.253/~ctwocndo/adoptions/adoption-application/?petname=A..%20%20Carmen
I am trying to take the petname and pre-populate it into an application that the user will fill out.
I tried referring to this code but it dosent seem to work for me, this is what I have.
function my_pre_display($form)
{
if (isset($_GET['petname']))
{
$form->setValues ('iphorm_2_1' => 'petname');
}
}
add_action('iphorm_pre_display_1', 'my_pre_display');
Any help is appreciated!
January 5, 2015 at 1:29 pm #13525Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
January 6, 2015 at 5:51 pm #13532Joe Dostie
ParticipantAwesome! As usual, you got it! 🙂
Now I have a NEW issue that appears to be introduced by this fix…
I had followed the topic of Date default value today and everything works perfect.
When I go to my Adoption page the date is per-populated with today’s date.
The weird part is, now if I go FROM my adoption link, the pet name is populated but the date function no longer seems to work.
So if I go to here:.
http://69.195.124.253/~ctwocndo/adoptions/adoption-application/ – The date is populated and all is good.But if I start from here first:
http://69.195.124.253/~ctwocndo/adoptions/adoption2/
Then select any pet
Then select the “Adopt Me” button on the top right
You will be redirected to the Adoption application but ONLY the pet name is populated. The date is no longer populated.I have a few guesses as to why:
1.) The variable (PetName) at the end of the URL are interfering with the DATE function
2.) The order of the action and function
3.) The date function needs to be integrated into the PetName function.
function mytheme_date_today()
{
$now = current_time('timestamp');return array(
'day' => date('j', $now),
'month' => date('n', $now),
'year' => date('Y', $now)
);
}
add_filter('iphorm_element_value_today', 'mytheme_date_today');
Then there is a bunch of code in between here….
function my_pre_display($form)
{
if (isset($_GET['petname']))
{
$form->setValues(array('iphorm_2_1' => $_GET['petname']));
}
}
add_action('iphorm_pre_display_2', 'my_pre_display');
add_filter('iphorm_element_value_today', 'mytheme_date_today');
January 12, 2015 at 10:14 am #13565Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- This reply was modified 11 years, 5 months ago by
- AuthorPosts
- You must be logged in to reply to this topic.