الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

هذا المطلووب مع الكوود ارجووكم ضروري بأسرع وقت يجب تعديله لزيادة الأسماء في لست

بدأه crazy_shark87 في 27 يوليو 2008 · 1 رد · 679 مشاهدة · في قسم البرمجة بــ Javascript
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

HW4

- استخدم البرنامج المرفق (HW4) وغير ما يلزم لتحقيق الشروط التالية:

1-استمرارية ظهور نافذة prompt مما يتيح للمستخدم إضافة إسم جديد.

2-إذا كتب المستخدم كلمة END أو end تظهر نافذة من نوع alert لتأكيد عرض الاسماء.

3-تظهر الأسماء بترتيب أبجدي .

4-تظهر الاسماء عكس الترتيب الأبجدي.

<!-- insert_names.html

The script in this document has an array of

names, name_list, whose values are in

alphabetic order. New names are input through

prompt. Each new name is inserted into the

name array, after which the new list is

displayed.

-->

<html>

<head>

<title>Name list </title>

</head>

<body>

<script type="text/javascript">

<!--

// The original list of names

var name_list = new Array("ahmad", "salem", "jaber", "fesal", "naser", "mohamad");

var new_name, index, last;

// Loop to get a new name and insert it

new_name = prompt("Please type a new name","")

last=name_list.lenght-1;

while (last >= 0 && name_list[last] > new_name)

{

name_list[last + 1] = name_list[last];

last = last - 1;

}

// Insert the new name into its spot in the array

name_list[last + 1] = new_name;

// Display the new array

document.write("<p><b>The new name list is:</b>",

"<br />");

for (index = 0; index < name_list.length; index++)

document.write(name_list[index], "<br />");

document.write("</p>");

//** end of the outer while loop

// -->

</script>

</body>

</html>

#2

البرنامج سهل وبسيط ولا يحتاج إلا للتفكير قليلاً هذا هو المثال المطلوب:

<!-- insert_names.html 
	 The script in this document has an array of
	 names, name_list, whose values are in 
	 alphabetic order. New names are input through
	 prompt. Each new name is inserted into the
	 name array, after which the new list is
	 displayed.
	 -->
<html>
	<head>
		<title>Name list </title>
	</head>
	<body>
		<script type="text/javascript">
		//  <!--
		// The original list of names
		var name_list = new Array("ahmad", "salem", "jaber", "fesal", "naser", "mohamad");
		var new_name, name, last;

		last = name_list.length - 1;
		// Loop to get a new name and insert it
		do{
		   new_name = prompt("Please type a new name","");
		   if(new_name != "END" && new_name != "end")
		   {
			 last++;
			 name_list[last] = new_name;
		   }
		  }while(new_name != "END" && new_name != "end");
		window.alert("The List of names will display now");

		// sortting function in alphabetic order
		  for(var i = 0; i < name_list.length; i++)
		  {
			for(var j = i + 1; j < name_list.length; j++)
			{
			  if(name_list > name_list[j])
			  {
				name = name_list;
				name_list = name_list[j];
				name_list[j] = name;
			  }
			}
		  }

		  document.write("The list in alphabetic order: <br />");
		 // display the list in alphabetic order
		 for(var i = 0; i < name_list.length; i++)
		  {
			document.write(name_list + "<br />");
		  }

		 document.write("<br /> The list in reverse order: <br />");
		// display the list in reverse order
		 for(var i = last; i >= 0; i--)
		  {
			document.write(name_list + "<br />");
		  }
		// -->
		</script>
	</body>
</html>

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…