DMande
DMande

Reputation: 341

Form redirect on submit not working, why?

I have the following code on my search form:

<form name="search" method="get" action="www.test.gr" enctype="multipart/form-data" 
     onsubmit="window.location.href='www.test.gr/search/document.getElementById('location').value';  
             return false;">

But it is not working. Maybe the quotes are wrong inside document.getElementById. Can anyone help please?

Upvotes: 0

Views: 44

Answers (1)

Alexandr Lazarev
Alexandr Lazarev

Reputation: 12882

You should concat string with object value. In your case document.getElementById('location').value statement is interpreted as a part of a string.

<form name="search" method="get" action="www.test.gr" enctype="multipart/form-data" onsubmit="window.location.href = 'www.test.gr/search/' + document.getElementById('location').value;  return false;">

Upvotes: 2

Related Questions