برگزیده های پرشین تولز

یکی به من بگه این برنامه چه کار میکنه

mehdi25

کاربر تازه وارد
تاریخ عضویت
28 اکتبر 2004
نوشته‌ها
1,318
لایک‌ها
2
محل سکونت
طهران
این یه تیکه از یه برنامه ایه که Page2 رو باز میکنه که در اون Page2 یه سرچ میشه و نتیجه رو به Page اصلی منتقل میکنه :wacko:

این برنامه اونه​
کد:
If strMode = "PM" Then

	Response.Write(vbCrLf &amp; &quot;        <tr>&quot; &amp; _
	vbCrLf &amp; &quot;         <td align=""right"" width=""15%"" class=""text"">&quot; &amp; strTxtToUsername &amp; &quot;*:</td>&quot; &amp; _
	vbCrLf &amp; &quot;         <td width=""70%"" class=""text"">&quot;)
         
         
         'Get the users buddy list if they have one

	'Initlise the sql statement
	strSQL = &quot;SELECT &quot; &amp; strDbTable &amp; &quot;Author.Username &quot;
	strSQL = strSQL &amp; &quot;FROM &quot; &amp; strDbTable &amp; &quot;Author INNER JOIN &quot; &amp; strDbTable &amp; &quot;BuddyList ON &quot; &amp; strDbTable &amp; &quot;Author.Author_ID = &quot; &amp; strDbTable &amp; &quot;BuddyList.Buddy_ID &quot;
	strSQL = strSQL &amp; &quot;WHERE &quot; &amp; strDbTable &amp; &quot;BuddyList.Author_ID=&quot; &amp; lngLoggedInUserID &amp; &quot; AND &quot; &amp; strDbTable &amp; &quot;BuddyList.Buddy_ID &lt;&gt; 2 &quot;
	strSQL = strSQL &amp; &quot;ORDER By &quot; &amp; strDbTable &amp; &quot;Author.Username ASC;&quot;

	'Query the database
	rsCommon.Open strSQL, adoCon

	Response.Write(vbCrLf &amp; &quot;          <input type=""text"" name=""member"" size=""15"" maxlength=""15"" value=""" & Server.HTMLEncode(strBuddyName) & """")
	If NOT rsCommon.EOF Then Response.Write(" onChange=""document.frmAddMessage.selectMember.options[0].selected = true;""")
	Response.Write(" />&quot;)
	Response.Write(vbCrLf &amp; &quot;          <a href=""JavaScript:openWin('pop_up_member_search.asp','profile','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1,width=440,height=255')""><img src=""" & strImagePath & "search.gif"" alt=""" & strTxtMemberSearch & """ border=""0"" align=""absmiddle""></a>&quot;)

	'If there are records returned then display the users buddy list
        If NOT rsCommon.EOF Then
        	
	Response.Write(vbCrLf &amp; &quot;          <span class=""text"">&quot; &amp; strSelectFormBuddyList &amp; &quot;:</span>&quot; &amp; _
	vbCrLf &amp; &quot;          <select name=""selectMember"" onChange=""member.value=''"">&quot; &amp; _
	vbCrLf &amp; &quot;            <option value="""">-- &quot; &amp; strTxtNoneSelected &amp; &quot; --</option>&quot;)

          	'Loop throuhgn and display the buddy list
          	Do While NOT rsCommon.EOF

          		Response.Write(&quot;<option value=""" & rsCommon("Username") & """>&quot; &amp; rsCommon(&quot;Username&quot;) &amp; &quot;</option>&quot;)

           		'Move to next record in rs
           		rsCommon.MoveNext
           	Loop
           	
	Response.Write(vbCrLf &amp; &quot;          </select>&quot;)

	Else
		Response.Write(vbCrLf &amp; &quot;	<input type=""hidden"" name=""selectMember"" value="""" />&quot;)
        End If

        'Reset server variables
	rsCommon.Close
	
	Response.Write(vbCrLf &amp; &quot;       </td>&quot; &amp; _
	 	       vbCrLf &amp; &quot;        </tr>&quot;)

End If


اینم برنامه Page2​

کد:
<% @ Language=VBScript %>
<% Option Explicit %>
<!--#include file="common.asp" -->
<!--#include file="functions/functions_send_mail.asp" -->
<%

Response.Buffer = True 


Dim strUsername	'Holds the users username


'If this is a post back then search the member list
If Request.Form("name") <> "" Then

	'Read in the username
	strUsername = Request.Form("name")
	
	'Take out parts of the username that are not permitted
	strUsername = disallowedMemberNames(strUsername)
	
	'Get rid of milisous code
	strUsername = formatSQLInput(strUsername)
	
	'Initalise the strSQL variable with an SQL statement to query the database
	strSQL = "SELECT " & strDbTable & "Author.Username "
	strSQL = strSQL & "FROM " & strDbTable & "Author "
	strSQL = strSQL & "WHERE " & strDbTable & "Author.Username Like '" & strUsername & "%' "
	strSQL = strSQL & "ORDER BY " & strDbTable & "Author.Username ASC;"
		
	'Query the database
	rsCommon.Open strSQL, adoCon
End If

%>
<html>
<head>
<meta name="copyright" content="Copyright (C) 2001-2006 Bruce Corkhill" />
<title>Member Search</title>

<%
'***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
Response.Write("<!--//" & _
vbCrLf & "/* *******************************************************" & _
vbCrLf & "Application: Web Wiz Forums ver. " & strVersion & "" & _
vbCrLf & "Author: Bruce Corkhill" & _
vbCrLf & "Info: http://www.webwizforums.com" & _
vbCrLf & "Available FREE: http://www.webwizforums.com" & _
vbCrLf & "Copyright: Bruce Corkhill ©2001-2006. All rights reserved" & _
vbCrLf & "******************************************************* */" & _
vbCrLf & "//-->" & vbCrLf & vbCrLf)
'***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
%>
     	
<script  language="JavaScript">

//Function to check form is filled in correctly before submitting
function CheckForm () {

	var errorMsg = "";
	
	//Check for a Username
	if (document.frmMemSearch.name.value==""){
	
		msg = "<% = strTxtErrorDisplayLine %>\n\n";
		msg += "<% = strTxtErrorDisplayLine1 %>\n";
		msg += "<% = strTxtErrorDisplayLine2 %>\n";
		msg += "<% = strTxtErrorDisplayLine %>\n\n";
		msg += "<% = strTxtErrorDisplayLine3 %>\n";
	
		alert(msg + "\n\t<% = strTxtErrorUsername %>");
		document.frmMemSearch.name.focus();
		return false;
	}
	
	return true;
}


//Function to place the username in the text box of the opening frame
function getUserName(selectedName)
{
	
	window.opener.document.<% If Request.QueryString("RP") = "BUD" Then Response.Write("frmBuddy.username") Else Response.Write("frmAddMessage.member") %>.focus();
	window.opener.document.<% If Request.QueryString("RP") = "BUD" Then Response.Write("frmBuddy.username") Else Response.Write("frmAddMessage.member") %>.value = selectedName;
	window.close();
}
</script>

</head>
<body bgcolor="<% = strBgColour %>" text="<% = strTextColour %>" background="<% = strBgImage %>" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
<div align="center" class="heading">
 <% = strTxtMemberSearch %>
</div>
<br />
<form method="post" name="frmMemSearch" action="pop_up_member_search.asp<% If Request.QueryString("RP") = "BUD" Then Response.Write("?RP=BUD") %>" onSubmit="return CheckForm();">
 <br />
 <table width="390" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="<% = strTableBorderColour %>" height="30">
  <tr> 
   <td height="2" width="483" align="center"> <table width="100%" border="0" cellspacing="1" cellpadding="2">
     <tr> 
      <td bgcolor="<% = strTableColour %>" background="<% = strTableBgImage %>" height="26"> <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr> 
         <td width="32%" align="right"><span class="text"><% = strTxtMemberSearch %>:</span>&nbsp;&nbsp;</td>
         <td width="68%"><input type="text" name="name" size="15" maxlength="15" value="<% = strUsername %>"> <input type="submit" name="Submit" value="<% = strTxtSearch %>"></td>
        </tr><%
'If this is a post back then display the results
If Request.Form("name") <> "" Then

%>        
        <tr> 
         <td align="right">&nbsp;</td>
         <td>&nbsp;</td>
        </tr>
        <tr> 
        <td width="32%" align="right"><span class="text"><% = strTxtSelectMember %>:</span>&nbsp;&nbsp;</td>
         <td width="68%"><select name="userName"><%

	'If there are no records found then display an error message
	If rsCommon.EOF then
		
		Response.Write("<option value="""" selected>" & strTxtNoMatchesFound & "</option>") 
	
	'Else there are matches found so display the result
	Else   
	
		'Loop through the recordset
		Do while NOT rsCommon.EOF  
		
			'Disply the usernames found
			Response.Write("<option value=""" & rsCommon("Username") & """>" & rsCommon("Username") & "</option>")       
           		
           		'Jump to the next record in recordset
           		rsCommon.MoveNext
           
           	Loop
           
        End If        
        %>
          </select> <input type="button" name="Button" value="<% = strTxtSelect %>" onClick="getUserName(frmMemSearch.userName.options[frmMemSearch.userName.selectedIndex].value);"></td>
        </tr><% 
        
        'Clean up
        rsCommon.Close
        
End If        

%>       
       </table></td>
     </tr>
    </table></td>
  </tr>
 </table>
</form>
<table width="<% = strTableVariableWidth %>" border="0" cellspacing="0" cellpadding="1" align="center">
 <tr> 
  <td align="center"><a href="JavaScript:onClick=window.close()">
   <% = strTxtCloseWindow %>
   </a> <br />
   <br />
   <br /> 
   <% 
'Reset Server Objects
Set rsCommon = Nothing 
adoCon.Close
Set adoCon = Nothing  


%>
  </td>
 </tr>
</table>
</body>
</html>



یکی بگه این برنامه چطوری اطلاعات رو از Page2 به صفحه اصلی میفرسته ...:( :wacko:​
 

amironline

Registered User
تاریخ عضویت
25 نوامبر 2003
نوشته‌ها
671
لایک‌ها
0
محل سکونت
Tabriz
من يه نگاهي بهش مي ندازم ولي به نظر ميرسه بايد از طريق فرم باشه ديگه
 

mehdi25

کاربر تازه وارد
تاریخ عضویت
28 اکتبر 2004
نوشته‌ها
1,318
لایک‌ها
2
محل سکونت
طهران
ممنون امیر جان منتظرم
 

amironline

Registered User
تاریخ عضویت
25 نوامبر 2003
نوشته‌ها
671
لایک‌ها
0
محل سکونت
Tabriz
من اصلا از اينجور كدا خوشم نمياد
آخه اينا رو اينجوري ميكنن كه تو محيط طراحي هيچي نشون نده و بعد از سرور كه اجرا شد كامل بشه
اين يه چند تا ارور داد برا كدهاي اولي
ولي همونطور كه حدس مي زدم يه فرم مخفي هستش

اينا رو ببين
select name
option value
input type=""hidden

و تو دومي
Request.Form("name")
 

mehdi25

کاربر تازه وارد
تاریخ عضویت
28 اکتبر 2004
نوشته‌ها
1,318
لایک‌ها
2
محل سکونت
طهران
امیر جان اینا رو خودم میدونم مشکل اصلی من این چند خطه
ببین وقتی صفحه لود میشه تو این TextBox خالیه و با کلیک روی این Image که لینکش یه Script OpenWin هست یه صفحه با اندازه های تعریف شده باز میکنه .​

کد:
Response.Write(vbCrLf &amp; &quot;          <input type=""text"" name=""member"" size=""15"" maxlength=""15"" value=""" & Server.HTMLEncode(strBuddyName) & """")
	If NOT rsCommon.EOF Then Response.Write(" onChange=""document.frmAddMessage.selectMember.options[0].selected = true;""")
	Response.Write(" />&quot;)
	Response.Write(vbCrLf &amp; &quot;          <a href=""javascript:openWin('pop_up_member_search.asp','profile','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1,width=440,height=255')""><img src=""" & strImagePath & "search.gif"" alt=""" & strTxtMemberSearch & """ border=""0"" align=""absmiddle""></a>&quot;)


حالا به عملیاتی که تو اون صفحه انجام میشه کار ندارم . فقط اینو بگم که در اون صفحه باز شده مقداری به این TextBox ( سورسش همین پایینه ) داده میشه و با کلیک روی باتون Select که مقدار ولیوی اون <% = strTxtSelect %> هست . مقداری که در TextBox قرار داره رو در همون TextBox قبلی ( صفحه قبل ) انتقال میده .:eek: البته خود این باتون هم فانکشن function getUserName رو اجرا میکنه که هرچی هست زیر سر همین فانکشنه

در واقع من یه همچین چیزی می خوام که بروبچ اینجا هنوز به سوال من جواب ندادن شاید هم وقت نکردن. بلاجبار خودم دست به کار شدم گفتم شاید بتونم یه چیزایی در بیارم . که توش گیر کردم اساس . :( :blink:​



HTML:
"><select name="userName"><%

	'If there are no records found then display an error message
	If rsCommon.EOF then
		
		Response.Write("<option value="""" selected>" & strTxtNoMatchesFound & "</option>") 
	
	'Else there are matches found so display the result
	Else   
	
		'Loop through the recordset
		Do while NOT rsCommon.EOF  
		
			'Disply the usernames found
			Response.Write("<option value=""" & rsCommon("Username") & """>" & rsCommon("Username") & "</option>")       
           		
           		'Jump to the next record in recordset
           		rsCommon.MoveNext
           
           	Loop
           
        End If        
        %>
          </select> <input type="button" name="Button" value="<% = strTxtSelect %>" onClick="getUserName(frmMemSearch.userName.options[frmMemSearch.userName.selectedIndex].value);"></td>


یه چیز دیگه
این چیه و چکار میکنه : اون قرمزه​

کد:
<input type=""text"" name=""member"" size=""15"" maxlength=""15"" value=""" & [color="Red"][COLOR="Red"]Server.HTMLEncode(strBuddyName)[/COLOR][/color] & """")
 
بالا