PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

C# code for searching, help needed

 
 
Lair Lair
Guest
Posts: n/a
 
      24th Apr 2009

How can I change this code to reflect just one textbox for searching for
firstname and lastname insead of having separate textboxes. Is this
possible?

Thank you.


<script language="javascript">
//function to handle enter on keyboard
function txtWildPeopleFinder_KeyDown(e)
{
if (e.keyCode == 13 || e.keyCode==10)
{
e.returnValue=false;
DoWildPeopleSearch();
return false;
}
else
return true;
}
//escape apostrophes in search strings
function escapestr(str)
{
return str.replace("'","%22");
}

//search function
function DoWildPeopleSearch()
{
var firstname = escapestr(document.all["firstname"].value);
var lastname = escapestr(document.all["lastname"].value);
var url;

//search on last name
if(firstname == "")
{
url = "/searchcenter/Pages/peopleresults.aspx?k=LastName%3A" +
lastname;
window.location=url;
return;
}

//search on first name
if(lastname == "")
{
url = "/searchcenter/Pages/peopleresults.aspx?k=FirstName%3A" +
firstname;
window.location=url;
return;
}

//first and last
url = "/searchcenter/Pages/peopleresults.aspx?k=lastname%3A" + lastname
+ "%20FirstName%3A" + firstname;
window.location=url;
return;
}
</script>

<table cellpadding="3" cellspacing="0" border="0" width="100%"
ID="Table3">
<tr>
<td width="80" nowrap>
First Name:
</td>
<td width="100%">
<input size="10" maxlength="100" id="firstname" name="firstname"
type="text" onkeydown="txtWildPeopleFinder_KeyDown(event)">
</td>
</tr>
<tr>
<td width="80" nowrap>
Last Name:
</td>
<td>
<input size="10" maxlength="100" id="lastname" name="lastname"
type="text" onkeydown="txtWildPeopleFinder_KeyDown(event)">
</td>
<tr>
<td>
<input type="button" onclick="DoWildPeopleSearch()" value="Search">
</td>

</tr>
</tr>
</table>

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Michaela Julia
Guest
Posts: n/a
 
      24th Apr 2009
Lair Lair wrote:

> How can I change this code to reflect just one textbox for searching for
> firstname and lastname insead of having separate textboxes. Is this
> possible?


How about this:
Use a dropdown listbox with items like "find in first name", "find in
last name", "find in first and last name" and change your if-block (or
use a switch) accordingly.
Checkboxes might be nice too. Depends on the layout of your form.

 
Reply With Quote
 
Pavel Minaev
Guest
Posts: n/a
 
      24th Apr 2009
On Apr 24, 8:27*am, Lair Lair <lairp...@hotmail.com> wrote:
> How can I change this code to reflect just one textbox for searching for
> firstname and lastname insead of having separate textboxes. Is this
> possible?
>
> Thank you.
>
> <script language="javascript">


This is a group about the C# programming language, not about
JavaScript.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed for Searching Folders Shawnsara Windows XP General 1 19th Apr 2004 11:35 AM
Help needed for Searching Folders Shawnsara Windows XP Help 1 19th Apr 2004 11:35 AM
Help needed for Searching Folders Shawnsara Windows XP Basics 1 19th Apr 2004 11:35 AM
Best practice needed to marshal STL data from managed code to unmanaged code & vice versa =?Utf-8?B?UFNQX1VOSl9NU19OZXdzZ3JvdXBfUmVxdWVzdEBw Microsoft VC .NET 0 11th Mar 2004 12:21 PM
Best practice needed to marshal STL data from managed code to unmanaged code & vice versa =?Utf-8?B?Sm9oYW5uZXMgVW5mcmllZA==?= Microsoft VC .NET 0 27th Feb 2004 09:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:27 AM.