I created a html code using javascript and it work fine in the html editor. But when I keep this code in the content editor webpart it doesn't work. Can someone tell me where the problem. It will be really helpful.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript">
function sendtogoogle() {
var dropdownValue=dropdown.options[dropdown.selectedIndex].value;
var url = 'http://google.com/?k=';
var inputs = document.getElementsByTagName('input');
for (var i = 0; i< inputs.length;i++) {
if (inputs[i].type == "text") {
if (inputs[i].value == ""){
url += "NULL";
url += "&";
}
else
{
url += inputs[i].value;
url += "&";
}
}
}
if (dropdownValue == ""){
url += "NULL";
}
else{
url += dropdownValue;
}
window.location.href = url;
}
</script>
<table style="width: 100%">
<tr>
<td style="width: 142px">First Name</td>
<td style="width: 192px"><input name="Text1" type="text"></td>
</tr>
<tr>
<td style="width: 142px">Last Name</td>
<td style="width: 192px"><input name="Text2" type="text"></td>
</tr>
<tr>
<td style="width: 142px">ID Number</td>
<td style="width: 192px"><input name="Text3" type="text"></td>
</tr>
<tr>
<td style="width: 142px">Document Type</td>
<td style="width: 192px"><select name="dropdown" id="dropdown">
<option></option>
<option>pdf</option>
<option>word</option>
<option>excel</option>
</select></td>
</tr>
<tr>
<td style="width: 142px"> </td>
<td style="width: 192px"><input type="submit" value="search" onclick="sendtogoogle()"/>
</td>
</tr>
</table>
</html>
According to the code when the user enter all the data like First Name, Last Name, ID Number and Document Type and click on the link, it should open a link like this www.google.com/?k=FirstName&LastName&IDNumber&DocumentType. But I don't know where I am going wrong.