JD Isaacks
JD Isaacks

Reputation: 57994

HTML Form method = HASH?

If I set my Form method to GET it will send the action page something like this:

action_page.php?key=value&foo=bar

But is there a way to make it send like this:

action_page.php#key=value&foo=bar

Because the page receiving the values relies on hash variables.

Thanks!

Upvotes: 1

Views: 2367

Answers (4)

Daniel Roseman
Daniel Roseman

Reputation: 599788

Are you sure that the page depends on 'hash variables'? That would be a very odd way to design a system. In particular, the elements after the hash are not guaranteed to be sent by the browser to the server, and in fact in most cases they are not. That means your PHP script will never receive the variables.

Upvotes: -1

Ozzy
Ozzy

Reputation: 10643

you can set up a "middle man" page which redirects the data like so

middleman.php:

<?php

$string = 'realpage.php#' . $_SERVER['QUERY_STRING'];

header('location: ' . $string);

?>

so in your form u would do:

<form action="middleman.php" method="get">

and that would send to middleman.php which inturn would redirect to realpage.php with the hash.

Upvotes: 3

codymanix
codymanix

Reputation: 29490

You could use javascript to dynamically create URL parameters like that from the form values.

Upvotes: 0

Dmitri Farkov
Dmitri Farkov

Reputation: 9681

You can do such a thing using javascript by appending to:

window.location.hash

Upvotes: 2

Related Questions