Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
134
rated 0 times [  135] [ 1]  / answers: 1 / hits: 8516  / 10 Years ago, sun, april 6, 2014, 12:00:00

I have a form in which there is one text field is provided with a submit button.On clicking submit button,it redirects to second php page from first php page.
index.php



<form action=submit.php method=get>

<input type=text name=search id=search />
<input type=submit value=submit onclick=convert() />
</form

<script type=text/javascript>
function convert()
{
alert(hi);
var str ;
str = document.getElementById(search).value;
document.writeln(str.toLowerCase());
}
</script>


On submitting the form,i want the url to become like submit.php?search=text



I want this text to be in lower case,although if text entered is uppercase.
Please guide me how to make this text lower case,I am using the above script for converting it to lower case.But its not converting the text in lower case in URL.



Please guide me on this..


More From » php

 Answers
1

You can do this only using javascript with a few extra stuff:



1) Give your <form> an id



<form action=submit.php method=get id=form1>


2) Make your <input> type as button. The reason for this is because we want to make sure the convert() function is executed first, and after that we will submit the form.



<input type=button value=submit onclick=convert() />


3) Finally javascript to:



function convert() 
{
alert(hi);
var str ;
str = document.getElementById(search);
str.value = (str.value.toLowerCase());
//get the form id and submit it
var form = document.getElementById(form1);
form.submit();
}


Fiddle


[#46258] Friday, April 4, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ellisc

Total Points: 533
Total Questions: 82
Total Answers: 90

Location: Bangladesh
Member since Thu, Aug 5, 2021
3 Years ago
;