homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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)

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)

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:

if($_GET['action'] == 'search')
// Do your search
// 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)

> 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)

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]


 1:22 am on Aug 28, 2006 (gmt 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)

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)

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


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved