如果那么声明 [英] If Then statement

查看:55
本文介绍了如果那么声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来自ASP世界,并且不知道javascript。在

下面的代码中,我正在尝试设置变量strPage的值,然后在redirect语句中使用

。该页面什么也没做。没有重定向。

synatx应该是什么?

谢谢!


< SCRIPT LANGUAGE =" JavaScript" >

如果Session(SoftHard)=" Hard"

{

strPage =" hardpage.asp?OrderNo = " &安培;会话(OrderNo);

}

如果会话(SoftHard)=" Soft"

{

strPage =" softpage.asp?OrderNo =" &安培;会话(" OrderNo");

}

setTimeout(" top.location.href = strPage",4000);

< ; / SCRIPT>

I''m coming from the ASP worl and have no clue to javascript. In the
following code, I''m trying to set the value for variable strPage, then use
that in the redirect statement. The page does nothing. No redirect at all.
What should the synatx be?
thanks!

<SCRIPT LANGUAGE="JavaScript">
if Session("SoftHard") = "Hard"
{
strPage = "hardpage.asp?OrderNo=" & Session("OrderNo");
}
if Session("SoftHard") = "Soft"
{
strPage = "softpage.asp?OrderNo=" & Session("OrderNo");
}
setTimeout("top.location.href = strPage",4000);
</SCRIPT>

推荐答案

Il Mon,2003年7月21日21:35:08 GMT,shank < SH *** @ tampabay.rr.com> ha

scritto nel messaggio

< g0 ********************** @ twister.tampabay。 rr.com> :
Il Mon, 21 Jul 2003 21:35:08 GMT, "shank" <sh***@tampabay.rr.com> ha
scritto nel messaggio
<g0**********************@twister.tampabay.rr.com> :
我来自ASP世界,并且不知道javascript。在下面的代码中,我正在尝试设置变量strPage的值,然后在重定向语句中使用
。该页面什么也没做。没有重定向。
synatx应该是什么?
谢谢!

< SCRIPT LANGUAGE =" JavaScript">
if Session(" SoftHard" ;)=" Hard"
{
strPage =" hardpage.asp?OrderNo =" &安培;会话(OrderNo);
}
如果会话(SoftHard)=软
{
strPage =" softpage.asp?OrderNo =" ; &安培;会话(" OrderNo");
}
setTimeout(" top.location.href = strPage",4000);
< / SCRIPT>
I''m coming from the ASP worl and have no clue to javascript. In the
following code, I''m trying to set the value for variable strPage, then use
that in the redirect statement. The page does nothing. No redirect at all.
What should the synatx be?
thanks!

<SCRIPT LANGUAGE="JavaScript">
if Session("SoftHard") = "Hard"
{
strPage = "hardpage.asp?OrderNo=" & Session("OrderNo");
}
if Session("SoftHard") = "Soft"
{
strPage = "softpage.asp?OrderNo=" & Session("OrderNo");
}
setTimeout("top.location.href = strPage",4000);
</SCRIPT>




我猜Session是你的函数:/


if语句要求括号包括布尔值

条件。此外,为了验证一个相等,你必须使用双等号(==)。


if(Session(" SoftHard")= =" Hard")

{

// blah blah

}

else if(Session(") ; SoftHard")==" Soft")

{

// blah blah

}

- -

artemis.alpeia



I guess Session is a function of yours :/

the if statement requires parenthesis to include the boolean
condition.

furthermore, to verify an equality you must use a double equal (==).

if (Session("SoftHard") == "Hard")
{
// blah blah
}
else if (Session("SoftHard") == "Soft")
{
// blah blah
}
--
artemis.alpeia


" shank" < SH *** @ tampabay.rr.com>写道:
"shank" <sh***@tampabay.rr.com> writes:
我来自ASP世界,并且不知道javascript。


Javascript语法源自C语法,就像C ++,Java,C#,

和许多其他语言一样。简短的版本是:


- 区分大小写!

- 条件和循环语句是:

if(< expr> )< stmt> [else< stmt> ]

while(< expr>)< stmt>

do< stmt> while(< expr>)

for(< expr> ;;< expr> ;;< expr>)< stmt>

需要括号(但是[]仅表示可选)

- 语句以分号结束,或以{表示。和'}"

- 比较是==,而=和是赋值。

- 局部变量用var声明在前面。


我不知道我可以推荐的任何Javascript教程,但是

我相信你可以通过输入找到很多javascript教程进入

Google。请注意,它们并不都是好的。

在下面的代码中,我试图设置变量
strPage的值,然后在redirect语句中使用它。页面确实没什么。根本没有重定向。 synatx应该是什么?谢谢!


如果您使用的浏览器能够提供有用的错误消息(

是,除了IE之外的任何东西),那么您可能会被告知语法

错误是。甚至IE的错误消息总比没有好,并且至少会告诉你错误在哪一行。

< SCRIPT LANGUAGE =" JavaScript" >


应该是

< script type =" text / javascript">

语言属性已弃用且类型属性是必需的

在HTML 4中。

如果Session(SoftHard)=" Hard"


应该是

if(Session(" SoftHard")==" Hard")

比较是 ==",其中" ="是作业。

{
strPage =" hardpage.asp?OrderNo =" &安培;会话(QUOT; OrderNo");


应该是

strPage =" hardpage.asp?OrderNo =" + Session(" OrderNo");

字符串连接运算符是+。

}
如果Session(" SoftHard")= "软"如果会话(SoftHard)只有两个结果,


可以更改为

其他



{
strPage =" softpage.asp?OrderNo =" &安培;会话(" OrderNo");
I''m coming from the ASP worl and have no clue to javascript.
Javascript syntax is derived from C syntax, just like C++, Java, C#,
and a lot of other languages. The short version is:

- case sensitive!
- conditional and loop statements are:
if ( <expr> ) <stmt> [ else <stmt> ]
while ( <expr> ) <stmt>
do <stmt> while ( <expr> )
for (<expr> ; <expr> ; <expr>) <stmt>
where parentheses are needed (but [ ] just means "optional")
- statements are ended with semicolon, or grouped with "{" and "}"
- comparison is "==", while "=" is assignment.
- local variables are declared with "var" in front.

I don''t know of any tutorials on Javascript that I can recommend, but
I am sure you can find a lot by entering "javascript tutorial" into
Google. Just be careful, they are not all good.
In the following code, I''m trying to set the value for variable
strPage, then use that in the redirect statement. The page does
nothing. No redirect at all. What should the synatx be? thanks!
If you used a browser capable of giving useful error messages (that
is, anythin but IE), then you would probably be told where the syntax
errors are. Even IE''s error messages are better than nothing, and will
at least tell you what line the error is on.
<SCRIPT LANGUAGE="JavaScript">
should be
<script type="text/javascript">
The language attribute is deprecated and the type attribute is mandatory
in HTML 4.
if Session("SoftHard") = "Hard"
Should be
if (Session("SoftHard") == "Hard")
Comparison is "==", where "=" is assignment.
{
strPage = "hardpage.asp?OrderNo=" & Session("OrderNo");
should be
strPage = "hardpage.asp?OrderNo=" + Session("OrderNo");
The string concatenation operator is "+".
}
if Session("SoftHard") = "Soft"
could be changed into just
else
if Session("SoftHard") only has two results.
{
strPage = "softpage.asp?OrderNo=" & Session("OrderNo");




字符串连接再次。

/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com

Art D''HTML:< ; URL:http://www.infimum.dk/HTML/randomArtSplit.html>

''没有判断的信仰只会降低精神神圣。''



String concatenation again.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D''HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
''Faith without judgement merely degrades the spirit divine.''


谢谢,但仍然没有重定向。使用你的例子,我有以下几点。

我假设代替//等等等等,我的陈述是正确的。我是b $ b猜测我的问题是实现我的Session变量

(Session(" OrderNo"))混合。有什么想法吗?

谢谢!


< SCRIPT LANGUAGE =" JavaScript">

if(Session(" SoftHard")=="很难")

{

strPage =" hardpage.asp?OrderNo ="& Session(" OrderNo");

}

else if(Session(" SoftHard")==" Soft")

{

strPage =" softpage.asp ?OrderNo ="& Session(" OrderNo");

}

setTimeout(" top.location.href = strPage",1000);

< / SCRIPT>


" artemis.alpeia"< it ******* @ alpeia.artemis>在消息中写道

新闻:5l ******************************** @ 4ax.com ...
Thanks, but still not redirecting. Using your example I have the following.
I''m assuming in lieu of // blah blah, my statements were correct. I''m
guessing that my problem is implementing my Session variables
(Session("OrderNo")"into the mix. Any thoughts?
thanks!

<SCRIPT LANGUAGE="JavaScript">
if (Session("SoftHard") == "Hard")
{
strPage = "hardpage.asp?OrderNo=" & Session("OrderNo");
}
else if (Session("SoftHard") == "Soft")
{
strPage = "softpage.asp?OrderNo=" & Session("OrderNo");
}
setTimeout("top.location.href = strPage",1000);
</SCRIPT>

"artemis.alpeia" <it*******@alpeia.artemis> wrote in message
news:5l********************************@4ax.com...
Il Mon,21 Jul 2003 21:35:08 GMT,shank< sh *** @ tampabay.rr.com> ha
scritto nel m essaggio
< g0 ********************** @ twister.tampabay.rr.com> :
Il Mon, 21 Jul 2003 21:35:08 GMT, "shank" <sh***@tampabay.rr.com> ha
scritto nel messaggio
<g0**********************@twister.tampabay.rr.com> :
我来自ASP世界,并且不知道javascript。在下面的代码中,我正在尝试设置变量strPage的值,然后
在重定向语句中使用它。该页面什么也没做。全部没有重定向
。 synatx应该是什么?
谢谢!

< SCRIPT LANGUAGE =" JavaScript">
如果Session(" SoftHard")=" Hard"
{
strPage =" hardpage.asp?OrderNo =" &安培;会话(OrderNo);
}
如果会话(SoftHard)=软
{
strPage =" softpage.asp?OrderNo =" ; &安培;会话(" OrderNo");
}
setTimeout(" top.location.href = strPage",4000);
< / SCRIPT>
I''m coming from the ASP worl and have no clue to javascript. In the
following code, I''m trying to set the value for variable strPage, then use that in the redirect statement. The page does nothing. No redirect at all. What should the synatx be?
thanks!

<SCRIPT LANGUAGE="JavaScript">
if Session("SoftHard") = "Hard"
{
strPage = "hardpage.asp?OrderNo=" & Session("OrderNo");
}
if Session("SoftHard") = "Soft"
{
strPage = "softpage.asp?OrderNo=" & Session("OrderNo");
}
setTimeout("top.location.href = strPage",4000);
</SCRIPT>



我猜Session是你的功能:/

if语句要求括号包括布尔
条件。

此外,验证一个平等你必须使用双等号(==)。

if(Session(" SoftHard")==" Hard")
{
// blah blah
}
else if(Session(" SoftHard")==" Soft")
//
// blah blah
}

-
artemis.alpeia



I guess Session is a function of yours :/

the if statement requires parenthesis to include the boolean
condition.

furthermore, to verify an equality you must use a double equal (==).

if (Session("SoftHard") == "Hard")
{
// blah blah
}
else if (Session("SoftHard") == "Soft")
{
// blah blah
}
--
artemis.alpeia



这篇关于如果那么声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆