Welcome to WebmasterWorld Guest from 54.226.241.8

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

     

Rhys

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

10+ Year Member



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?

barns101

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

10+ Year Member



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>

Rhys

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

10+ Year Member



> 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

Rhys

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

10+ Year Member



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]

barns101

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

10+ Year Member



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.

Rhys

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

10+ Year Member



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" />

barns101

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

10+ Year Member



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


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

Featured Threads

Hot Threads This Week

Hot Threads This Month