Hi Everyone

I just started to learn PHP and coding and stuff :o ... an I want to ask this
I have easy form made from few select (dropdown) options where people can choose attributes they want to search later on. All I need is to put those options together and to php file send just one line of text "New Red". So how can I put those two attributes together?

here is the script:

<form name="myform" action="/search.php">
<p>Search:
<select name="Atribute1">
<option value="any" selected="selected">Any</option>
<option value="New">New</option>
<option value="Old">Old</option>
</select>
<select name="Atribute2">
<option value="any" selected="selected">Any</option>
<option value="Red">Red</option>
<option value="Blue">Blue</option>
</select>
<br>
<a href="javascript: submitform()">Search</A> </p>
</form>
<SCRIPT language="JavaScript">
function submitform()
{
document.myform.submit();
}
</SCRIPT>

this is what I need to get ".../search.php?xSearch=New+Red"

    	if ($_POST['Atribute1']) {
    		$atribute1	= $_POST['Atribute1'];	
    		$atribute2	= $_POST['Atribute2'];
    		$both		 = $atribute1 . "+" . $atribute2;
    
    	header("Location: search.php?xSearch=$both");
    	exit();
    }
    

    You could chop it down by a few lines but the above should at least explain the process.

    Also, why are you using a text link with javascript to submit your form? Just use a normal submit button and remove the javascript altogether.

    <input name="submitbutton" type="submit" value="Submit" />

      It was just beginning. I didn't know where to start... 😕
      Thanks a lot anyway. It's working great

        Write a Reply...