Welcome to WebmasterWorld Guest from 54.162.109.245

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Pass variables and automatically submit them

How to pass info to a form page and have it auto-submit

     
11:25 pm on Aug 27, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:June 17, 2001
posts:130
votes: 0


I am trying to pass variables to a new form page and have it automatically action the form - is this possible?

<a href="http://mapsite.com/map.aspx?Address=whatever&City=Someplace">map link</a>

This works in the sense that the new search page appears with the form fields filled in; but how do I get it to automatically do the search?

12:32 am on Aug 28, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 6, 2005
posts:575
votes: 0


Yes, it's possible.

<a href="http://mapsite.com/map.aspx?Address=whatever&City=Someplace">map link</a>

Aren't you in the wrong forum? ;)

You need to tell the script that it should be performing a search. You can use an if statement like this:


<?php
if($_GET['action'] == 'search')
{
// Do your search
}
else
{
// Show the search form
}
?>

And your link would be something like this:

<a href="http://example.com/map.aspx?action=search&Address=whatever&City=Someplace">map link</a>
12:49 am on Aug 28, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:June 17, 2001
posts:130
votes: 0


> Aren't you in the wrong forum?

This is part of a serverside php page.

Sorry to not explain clearly - This is part of a real estate site and I need the variables of address and city to pass to this map page and automatically display the correct location on the resulting map.

My code fills in the fields, but will not activate the submit (Search) button

12:54 am on Aug 28, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:June 17, 2001
posts:130
votes: 0


This is my actual code:

global $lang;
$map_string = "?Name=$address&Location=$city&onload=document.frm1.submit()";
if ($url_only == 'no') {
$display = "<a href=\"http://www.somesite.com/map/Default.aspx$map_string\" >$lang[map_link]</a>";
} else {
$display = "http://somesite.com/$map_string";

[edited by: dreamcatcher at 12:16 pm (utc) on Aug. 28, 2006]
[edit reason]
[1][edit reason] Generalized url [/edit]
[/edit][/1]

1:22 am on Aug 28, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 6, 2005
posts:575
votes: 0


I take it that the maps site is an external website that you do not have scripting access to? If so, it's harder to say how you would get someone else's form to submit simply by passing variables in the URL. It's probably possible if you look at the form fields that they use.
1:27 am on Aug 28, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:June 17, 2001
posts:130
votes: 0


This is the actual submit code for the target page :

<input name="btnSearch" id="btnSearch" type="submit" value="SEARCH" onclick="return onSubmitClick(['Name', 'Location'], true)" class="button" />

3:01 am on Aug 28, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 6, 2005
posts:575
votes: 0


It looks like you would need to have the following variables in the URL:


script.php?btnSearch=SEARCH&Name=whatever&Location=whatever