Welcome Guest, Not a member yet? Register   Sign In
Form to URL weird default behavior
#1

[eluser]Unknown[/eluser]
I have a project where I am searching by either zip code or state. I have a page that works like this:

In the view of a url like this: domain.com/show/

<form id="searchForm" action="http://domain.com/show/" method="post">
<input id="zip" name="zip" type="text" size="5" maxlength="5" />
<input id="searchSubmit" name="searchSubmit" type="submit" value="Submit" />
</form>

When I submit it automatically goes to domain.com/show/90210 (or whatever zip was used). It does this automatically.

I have another view that has:
<form action="http://domain.com/show/" method="post" id="searchForm">
<select name="state" id="state" class="defaultBody">
<option value="">Choose a State</option>
<option value='AK'>Alaska</option> ETC
</select>
&lt;input type="submit" name="submit" id="searchSubmit"value="Search"&gt;
&lt;/form&gt;

When I submit it automatically goes to domain.com/show/AK (or whatever zip was used). It does this automatically.

SINGULARLY THEY WORK 100%. I like how the search term state or zip is added to the url. The controller looks like this:

public function show($searchValue = NULL){
//determine if zip or state and call the right model to search
}

So now the problem is if I have the 2 forms on one view, the first one is the only one that will work, it can be either the zip or state form. The first one will take it to the proper url but the 2nd one will only reload the page and send no value to the controller.

I don't have any code that pushes these values into the URL, just a simple form that submits to the url domain.com/show/. How does it get automatically added to the URL? Then how does this work so that it is only working on ONE of my forms per page? Thanks for any help in advance. I am pulling my hair out on this one.




Theme © iAndrew 2016 - Forum software by © MyBB