So I've got a form with a submit button and a text input...
I want: http://localhost/
to become: http://localhost/#q=
I did a solution in javascript which involves changing the "action" of the form to the url with the hash onclick.. but this doesn't work in IE.
Anyone have a solution that works on all browsers?
Adding and Removing Keys and Values And, you can add keys and values to a hash table by using the addition operator ( + ) to add a hash table to an existing hash table. For example, the following statement adds a "Time" key with a value of "Now" to the hash table in the $hash variable.
To append a new value to the array of values associated with a particular key, use push : push @{ $hash{"a key"} }, $value; The classic application of these data structures is inverting a hash that has many keys with the same associated value. When inverted, you end up with a hash that has many values for the same key.
In Ruby, Hash is a collection of unique keys and their values. Hash is like an Array, except the indexing is done with the help of arbitrary keys of any object type. In Hash, the order of returning keys and their value by various iterators is arbitrary and will generally not be in the insertion order.
Each key can only have one value. But the same value can occur more than once inside a Hash, while each key can occur only once.
I ran into a similar problem with IE not pulling in the hash from the form action.
I had a form
<form action="/#search" id="search-form">
<input type="text" class="search-query" placeholder="Search" name="q">
</form>
When I submitted this form in anything but IE the page went to
/?q=searchparams#search
But in IE it went to
/?q=searchparams
To solve this I used JQuery to bind to the submit action and redirect to the page I wanted it to go to.
$("#search-form").submit(function() {
var query = $('input[name="q"]').val();
window.location.href = 'index.php?q='+query+'#search';
return false;
});
It's been working fine since.
<script>
function add_hash() {
window.location.hash = "q=";
}
</script>
<form onsubmit="add_hash(); return false;">
Not sure what you're doing with this, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With