Avatar billede mxs Nybegynder
29. juni 2003 - 20:21 Der er 13 kommentarer og
1 løsning

Hvorfor virker det ikke?

Hey alle i asp geeks :P

Jeg har et lille problem med min kode her:
<%
dim Menu
Menu = request.querystring("Menu")

%>

<%
Dim link
if Menu = "Firma" then
link = Firmaluk
elseif Menu = "Firmaluk" then
link = Firma
else
link = Firma
End if
%>
<table border="0" cellpadding="0" cellspacing="0" width="100%" >
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p>Forsiden</p></span></td>
</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='default.asp?Menu=Nyhed'" span style="cursor='hand'"><span class="2"><p>Nyheder</p></span></td>
</tr>
<%
if Menu  = "Nyhed" then
%>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p><b>.Seneste Nyhed</b></p></span></td>
</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p><b>.Alle Nyheder</b></p></span></td>
</tr>

<%else%>

<%End if%>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='default.asp?Menu=<%  & link & %>'" span style="cursor='hand'"><span class="2"><p>Om

firmaet</p></span></td>
</tr>

<%
if Menu = "Firma" then
%>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p><b>.Historie</b></p></span></td>
</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p><b>.Personerne bag</b></p></span></td>
</tr>

<%elseif Menu = "Firmaluk" then%>
<%End if%>

<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p>Service</p></span></td>

</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p>Find os</p></span></td>

</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p>Menuen</p></span></td>

</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p>Menuen</p></span></td>

</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p>Menuen</p></span></td>

</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p>Menuen</p></span></td>

</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p>Menuen</p></span></td>

</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p>Menuen</p></span></td>

</tr>
<tr>
<td class="bottom" bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p>Kontakt os</p></span></td>

</tr>
</table>

Jeg roder rundt i min definationer og det volder mig problemer, men hvad mere kan man forlange når man ikke har læst asp så længe? Men jeg tror nu godt i kan regne den ud!!! For jeg ved ikke hvordan jeg skal placere mine " - tegn!!! Det er jeg ikke så god til endnu.

På forhånd tak, MxS
Avatar billede eagleeye Praktikant
29. juni 2003 - 20:27 #1
Hvis du skriver sådan her:

link = Firma

Så ligger man variablen Firma ind i variablen link. Skriver man sådan her

link = "Firma"

Så ligger man teksten "Frima" ind i variablen link
Avatar billede eagleeye Praktikant
29. juni 2003 - 20:29 #2
Husk at if sætninger er case senativ så hvis menu = "firma" vil denne ikke blive sand, det skal være med stort F, "Firma":

if Menu = "Firma" then
Avatar billede Slettet bruger
29. juni 2003 - 20:31 #3
Eller If ucase(menu) = "FIRMA"

så er det ligemeget hvordn man skriver firma
Avatar billede mxs Nybegynder
29. juni 2003 - 20:36 #4
Jeg har sat:

link ="Firma" og tjekket case! Det ser rigtig ud, men den kommer stadig med fejlen:

Fejltype:
Der opstod en Microsoft VBScript-kompileringsfejl (0x800A0400)
En sætning var ventet
/hp/templates/menu.asp, line 38
& link &
Avatar billede Slettet bruger
29. juni 2003 - 20:39 #5
Ret onclick="location.href='default.asp?Menu=<%  & link & %>'" span style="cursor='hand'"><

til
onclick="location.href='default.asp?Menu=<%=link%>'" span style="cursor='hand'"><
Avatar billede mxs Nybegynder
29. juni 2003 - 20:42 #6
Thx m8!!!

Hvorfor virkede det ikke med & link &?
Avatar billede Slettet bruger
29. juni 2003 - 20:46 #7
Fordi du putter en asp variabel ind i en html linie, så skal det skrives som
<%=variabelnavn%>
Avatar billede mxs Nybegynder
29. juni 2003 - 20:46 #8
Hehe kk hvis du vil have nogle points for at løse den her så kom med et svar.
Avatar billede Slettet bruger
29. juni 2003 - 20:47 #9
ok
Avatar billede mxs Nybegynder
29. juni 2003 - 21:11 #10
Hey lige et hurtigt spm mere som jeg håer du kan hjælpe mig med!

Jeg har lavet koden lidt om og vil gerne bruge en funktion så jeg ikke skal gentage mig så meget, men jeg har ikke arbejdet med funktioner før og vil gerne spørge dig om hvordan jeg får den her til at virke... Igen tror jeg at det er mine "" som jeg ikke kan få rigtig på plads!

Koden er her:
<%
Dim link, background

function opse(name)
if Menu = " '" & name & "' " then
    link = "Firmaluk"
   

elseif Menu = " '"& name & "' " then
    link = "Firma"
   

else
    link = "'"& name & "'"
   
End if
End function
%>
<table border="0" cellpadding="0" cellspacing="0" width="100%" >
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p>Forsiden</p></span></td>
</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='default.asp?Menu=Nyhed'" span style="cursor='hand'"><span class="2"><p>Nyheder</p></span></td>
</tr>
<%
if Menu  = "opse(Nyhed)" then
%>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p><b>.Seneste Nyhed</b></p></span></td>
</tr>
<tr>
<td bgcolor="white" onmouseover="this.style.background='orange'" onmouseout="this.style.background='white'"

onclick="location.href='xxx.asp'" span style="cursor='hand'"><span class="2"><p><b>.Alle Nyheder</b></p></span></td>
</tr>

<%else%>

<%End if%>

Håber jeg kan få lidt gratis hjælp :)
Avatar billede Slettet bruger
29. juni 2003 - 21:21 #11
Du skal bytte lidt om da name jo er din Menu

If name = "Firma" Then o.s.v.

Men det giver altså ingen optimering det er bare en anden måde at skrive det samme på :-)
Avatar billede mxs Nybegynder
29. juni 2003 - 21:28 #12
Det gør jo at jeg ikke skal skrive så mange if sætninger!
Avatar billede Slettet bruger
29. juni 2003 - 21:32 #13
Ja ok da.
Avatar billede mxs Nybegynder
29. juni 2003 - 21:33 #14
Men jeg tror at jeg dropper den.. .Den melder fejl.... :(
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester