Forum Katalogu Ciekawych Stron Strona Główna  Forum Katalogu Ciekawych Stron Strona Główna  
 
FAQ  FAQ   Szukaj  Szukaj   Użytkownicy  Użytkownicy   Ranking systemów  Ranking systemów   Grupy  Grupy  
 
Rejestracja  ::  Zaloguj Zaloguj się, by sprawdzić wiadomości
 
Forum Katalogu Ciekawych Stron Strona Główna » JavaScript i inne języki skryptowe » Kilka problemów ze skryptem w JS

Napisz nowy temat  Odpowiedz do tematu
 Kilka problemów ze skryptem w JS « Zobacz poprzedni temat :: Zobacz następny temat » 
Autor Wiadomość
yellowww
PostWysłany: 22 Cze 2008, 11:01    Temat postu: Kilka problemów ze skryptem w JS Odpowiedz z cytatem Zacytuj zaznaczone

Nowicjusz
Nowicjusz

Dołączył: 22 Cze 2008
Posty: 1


Witam

Ucze sie od jakis 2 mies. Java Scriptu i rozwiazuje sobie rozne problemy z ksiazek i z netu... Rozwiazuje teraz pewne zadanie, ale utknąłem w jednym miejscu i nie wiem jak to dalej ugryźć. Wiem, ze w kodzie jest ogólny chaos i nie powinno być tak dużo if'ów, ale nie wiem jak to przerobić na for...in'y.
Poniżej przedstawiam treść problemu i tłumaczenie gdyz zadanie pochodzi z angielskiej strony.

The company you work for has asked you to create two user interfaces: one optimised for the browser Internet Explorer and the other for Netscape Navigator. Using the functions for checking browser type, detect what browser the user has and if it’s the wrong page for that browser redirect to the other page. Each page should have a heading telling you what page is loaded.

The user interface should allow the user to pick the computer system of their dreams, similar in principle to the e-commerce sites selling computers over the Internet like www.dell.co.uk , www.pcworld.co.uk . The user should be given a choice of processor type, speed, RAM size, hard drive size, screen size, type of operating system, and the option to add additional components like different types of optical drives, graphics card, sound card, and peripherals such as speakers, printers, scanners, mouse and keyboard. The user should also be able to add utility software such as anti-virus software and an application software suite. As the user changes the selection, the price of the computer system should update automatically and notify the user of the cost of the system as they have specified it by updating contents of a textarea. This means that all the details of the system the user has selected and the total cost should be displayed in the textarea. The update should take place on clicking a button.
Create three simple banners for your user interface which are displayed randomly when the page loads


TŁUMACZENIE:

Firma, dla której pracujesz poprosiła Cię żeby dostarczyć 2 interfejsy użytkownika (w sensie strony internetowe). Jedna zoptymalizowaną dla wyszukiwarki Internet Explorer i drugi dla Netscape Navigator (w sumie moze byc Firefox). Używając funkcji dla sprawdzenia typu wyszukiwarki, wykryć którą wyszukiwarkę ma użytkownik. Jeśli strona jest zła dla danej wyszukiwarki przekierunkuj do właściwej strony.
Kazda strona powinna miec nagłówek mówiący, która strona jest załadowana.

Interfejs uzytkownia powinien pozwolic uzytkownikowi wybrac komponenty do komputera swoich marzen, podobnych w zasadzie do tych na stronach jak: www.dell.co.uk... Uzytkownik powinien miec wybór typu procesora, predkosci, pamiec RAM, rozmiar dysku twardego, rozmiar monitora, typ systemu operacyjnego i opcje dodania dodatkowych kompnentów jak różne typy napędów optycznych, kart graf, muzycznych i peryferiów takich jak glosniki, drukarki, skanery, myszy i klawiatury. Uzytkownik powinien rowniez byc zdolny do dodania uzytecznego oprogramowania takiego jak antywirus i inne pasujace aplikacje.
Kiedy uzytkownik zmieni zaznaczenie, cena komponentów powinna uaktualniać się automatycznie i powiadamiać o kosztach komponentów w specjalnym oknie tekstowym. To znaczy, że wszystkie detale komp. uzytkownik wybrał i całkowity koszt powinien być wyświetlany w tym oknie.
Uaktualnienie powinno mieć miejsce przez kliknięcie na przycisk.
Stwórz 3 proste banery do twoich stron ktore sa wyswietlane losowo kiedy strona jest załadowana.




Na razie zrobiłem tyle i nie wiem niestety jak ruszyć z tym dalej. A mianowicie:

Mógłby mi ktos podpowiedzieć jak zrobić aby po wybraniu produktów wyświetlały się poszczególne komponenty w oknie (taka lista wszystkich wybranych rzeczy) i po naciśnięciu Calculate żeby to wszystko zsumować.

I teraz tak jak mówi treść zadania mam stworzyć 2 strony. Pierwsza dedykowana dla IE druga niech to będzie Firefox. Powiedzmy, że otwieram stronę przeznaczoną tylko dla IE w Firefoxie i mnie przekierowuje do właściwej zrobionej dla Firefoxa. Nie wiem za bardzo jak to zrobić n

I jak można by zrobić wyświetlanie banerów losowo. Powiedzmy, że otwieram stronę 1 i razem z nią otwiera się baner 1. Jak otwieram stronę 2 otwiera się baner 2, a jak przejdę znowu do strony 1 otwiera się baner numer 3. Po prostu chodzi mi o to, żeby banery wyświetlały się losowo.


Daje screena jakby ktos nie wiedział o co mi chodzi


Daje jeszcze kod:
Kod:
<html>
<head>
<body bgcolor="orange">
<img src="firstbanner.gif">

<title>HTML Form</title>


&lt;script language="JavaScript" type="text/JavaScript">
if(navigator.appName == "Mozilla" || navigator.appName == "Netscape")
{
alert("You're using the Mozilla Firefox.")
}
else if(navigator.appName == "Netscape")
{
alert("You're using a Netscape browser.")
}
else if(navigator.appName == "Microsoft Internet Explorer")
{
alert("You're using the Internet Explorer browser.")
}
else
{alert ("I am not sure which browser you are using")
}
</script>
&lt;script language="JavaScript" type="text/javascript">
function adding_numbers_onclick()
{
var total=0;
var formElement;
formElement=document.form1.item1
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item2
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item3
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item4
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item5
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item6
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item7
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item8
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item9
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item10
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item11
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item12
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item13
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item14
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item15
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item16
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item17
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item18
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item19
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item20
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item21
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item22
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item23
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item24
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item25
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item26
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item27
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}
formElement=document.form1.item28
if (formElement.checked==true)
{
total=total+parseFloat(formElement.value);
}





formElement=document.form1.number
if(formElement[0].checked==true)
{
total=total+parseFloat(formElement[0].value);
}

else if(formElement[1].checked==true)
{
total=total+parseFloat(form.Element[1].value);
}

else if(formElement[2].checked==true)
{
total=total+parseFloat(form.Element[2].value);
}

else if(formElement[3].checked==true)
{
total=total+parseFloat(form.Element[3].value);
}

Details="The total order cost is "+total+"\n";
document.form1.txtorder.value=Details;
}
</script>


<title>HTML Form</title>
<body>
<form name=form1>

<table>
<b>TYPE OF PROCESSOR</b>
<tr><td><input type="checkbox" name="item1" value="20"></td><td>Intel Celeron E1200</td></tr>
<tr><td><input type="checkbox" name="item2" value="100"></td><td>Intel Core 2 Duo E8500</td></tr>
<tr><td><input type="checkbox" name="item3" value="60"></td><td>AMD Athlon 64 X2 5000+</td></tr>
<tr><td><input type="checkbox" name="item4" value="80"></td><td>AMD Phenom 9850</td></tr>
</table>
<BR>
<table>
<b>MOTHERBOARD</b>
<tr><td><input type="checkbox" name="item5" value="25"></td><td>Asus P5K Socket 775</td></tr>
<tr><td><input type="checkbox" name="item6" value="120"></td><td>Gigabyte X46-DQ6 Socket 775</td></tr>
<tr><td><input type="checkbox" name="item7" value="20"></td><td>ABIT KN9 Socket AM2</td></tr>
<tr><td><input type="checkbox" name="item8" value="30"></td><td>Foxconn 560+ Socket AM2</td></tr>
</table>
<BR>
<table>
<b>GRAPHIC CARD</b>
<tr><td><input type="checkbox" name="item9" value="100"></td><td>Asus GeForce 9800GTX 512mb 256bit</td></tr>
<tr><td><input type="checkbox" name="item10" value="60"></td><td>Palit 8800GT 1024mb 256bit</td></tr>
<tr><td><input type="checkbox" name="item11" value="80"></td><td>Foxconn Radeon 3870X2 512mb 256bit</td></tr>
<tr><td><input type="checkbox" name="item12" value="30"></td><td>Sparkle Radeon 3650 256mb 128 bit</td></tr>
</table>
<BR>
<table>
<b>MEMORY RAM</b>
<tr><td><input type="checkbox" name="item13" value="20"></td><td>2x1GB G.Skill PQ DDR2-800MHz</td></tr>
<tr><td><input type="checkbox" name="item14" value="40"></td><td>2x1GB Crucial Ballistix DDR2-1066MHz</td></tr>
<tr><td><input type="checkbox" name="item15" value="50"></td><td>2x2GB Kingston Value DDR2-667MHz</td></tr>
<tr><td><input type="checkbox" name="item16" value="10"></td><td>2x512mb A-Data DDR2-533MHz</td></tr>
</table>
<BR>
<table>
<b>HARD DISK</b>
<tr><td><input type="checkbox" name="item17" value="60"></td><td>Samsung 500GB</td></tr>
<tr><td><input type="checkbox" name="item18" value="100"></td><td>Seagate 750GB</td></tr>
<tr><td><input type="checkbox" name="item19" value="40"></td><td>WD Caviar 320GB</td></tr>
<tr><td><input type="checkbox" name="item20" value="20"></td><td>Samsung 250GB</td></tr>
</table>
<BR>
<table>
<b>MONITOR</b>
<tr><td><input type="checkbox" name="item21" value="200"></td><td>Asus MW221U 22"</td></tr>
<tr><td><input type="checkbox" name="item22" value="225"></td><td>Samsung SB226 22"</td></tr>
<tr><td><input type="checkbox" name="item23" value="140"></td><td>Neovo 19"</td></tr>
<tr><td><input type="checkbox" name="item24" value="400"></td><td>Apple 26"</td></tr>
</table>
<br>

<table>
<b>OPERATING SYSTEM</b>
<tr><td><input type="checkbox" name="item25" value="40"></td><td>Windows XP Home Edition</td></tr>
<tr><td><input type="checkbox" name="item26" value="70"></td><td>Windows Vista Home Premium</td></tr>
<tr><td><input type="checkbox" name="item27" value="5"></td><td>Linux Mandriva 10</td></tr>
<tr><td><input type="checkbox" name="item28" value="90"></td><td>Windows Vista Ultimate 64bit</td></tr>
</table>
<BR>
<table>
<b>DVD</b>
<tr><td><input type="radio" name="number" value="15"></td><td>Samsung DVD+/-RW</td></tr>
<tr><td><input type="radio" name="number" value="10"></td><td>LG DVD+/-RW</td></tr>
<tr><td><input type="radio" name="number" value="20"></td><td>OptiARC DVD+/-RW</td></tr>
<tr><td><input type="radio" name="number" value="40"></td><td>Plextor DVD+/-RW</td></tr>
</table>
<BR>
<table>
<b>CASE</b>
<tr><td><input type="radio" name="number" value="45"></td><td>Raidmax Smilodon</td></tr>
<tr><td><input type="radio" name="number" value="25"></td><td>Cooler Master 330</td></tr>
<tr><td><input type="radio" name="number" value="120"></td><td>Antec P182</td></tr>
<tr><td><input type="radio" name="number" value="35"></td><td>Cooler Master 340</td></tr>
</table>
<BR>
<table>
<b>SPEAKERS</b>
<tr><td><input type="radio" name="number" value="80"></td><td>Logitech T5500</td></tr>
<tr><td><input type="radio" name="number" value="70"></td><td>Creative Soundworks 440</td></tr>
<tr><td><input type="radio" name="number" value="50"></td><td>Genius P-183</td></tr>
<tr><td><input type="radio" name="number" value="30"></td><td>Manta Multimedia R3330</td></tr>
</table>
<BR>
<table>
<b>PRINTER</b>
<tr><td><input type="radio" name="number" value="20"></td><td>HP 3220</td></tr>
<tr><td><input type="radio" name="number" value="40"></td><td>Lexmark 4450</td></tr>
<tr><td><input type="radio" name="number" value="60"></td><td>Epson D820</td></tr>
<tr><td><input type="radio" name="number" value="80"></td><td>Canon 5000</td></tr>
</table>
<BR>
<table>
<b>KEYBOARD</b>
<tr><td><input type="radio" name="number" value="10"></td><td>Microsoft</td></tr>
<tr><td><input type="radio" name="number" value="20"></td><td>Logitech Wave</td></tr>
<tr><td><input type="radio" name="number" value="80"></td><td>Logitech DiNovo</td></tr>
<tr><td><input type="radio" name="number" value="30"></td><td>Genius</td></tr>
</table>
<BR>
<table>
<b>MOUSE</b>
<tr><td><input type="radio" name="number" value="40"></td><td>Razer DeathAdder</td></tr>
<tr><td><input type="radio" name="number" value="50"></td><td>Logitech G5</td></tr>
<tr><td><input type="radio" name="number" value="70"></td><td>Logitech G7</td></tr>
<tr><td><input type="radio" name="number" value="10"></td><td>Genius</td></tr>
</table>
<BR>

<BR>


<p><input type="button" value="Check the price" name="butCheck" onclick="adding_numbers_onclick()"></p>
<textarea rows=20 cols=50 id=txtorder name=txtorder>
</textarea>
<p><input type="button" value="Calculate" name="butCheck" onclick="adding_numbers_onclick()"></p>
</form>
</body>
</html>
Powrót do góry
Zobacz profil autora Wyślij prywatną wiadomość
KCS
Wysłany:     Temat postu: Reklama w KCS







Powrót do góry
Wyświetl posty z ostatnich:   
Napisz nowy temat  Odpowiedz do tematu Strona 1 z 1


Forum Katalogu Ciekawych Stron Strona Główna » JavaScript i inne języki skryptowe » Kilka problemów ze skryptem w JS
Skocz do:  



Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach


katalog stron | forum
Powered by phpBB © 2005 phpBB Group