-
Java vs VBScript
When I am using VBscript in HTML-code I can recieve text from e.g. a textbox with this code:
<%var1=request.form("theText")%>
or
<%var1=request.querystring("theText")%>
Can this be done in JavaScript, or must I use Perl or cgi or something else if I want it to work on Netscape ??
-
The question is not wholly clear to me. In server processing, HTML is sent to a browser, and it does not matter whether a user is using IE or NetScape.
For serverside processing on a WebServer with an ASP engine you can use both VBScript and JavaScipt, though I have no experience with JavaScript. But I know it is possible and you can approach the Request-object.
-
If the server is set up for it, you can also use PerlScript for ASP processing......
-
Javascript only works on with the current page loaded as it works client side, not server side. If you want to get data from a form client side use the document object modal.
<script language="javascript" type="text/javascript">
function displayItems(){
for (i=0;i=document.form1.elements.length;i++){
alert (document.form1.elements[i].value);
}
}
</script>
<form name="form1">
<input type="text" name="text1">
<input type="text" name="text2">
<input type="text" name="text3">
</form>
or you can reference an Item directly : -
<script language="javascript">
alert (document.form1.text1.value);
</script>
but this is only client side. You cant hit the forms submit button and use javascript to get data from the form, only something like ASP, PHP or CGI/Perlscript will work as it works with the Server.
-
You can't do what you are trying to do in this way. *ALL* Server side code executes before the html is sent to the browser. To get values from the client side DOM you have to either submit the data back to the page and get it from the Request.Form collection or use querystrings to re-request the page, passing the values in the URL line and get them from the Request.Querystring collection.
-
Yes, but can that be done in JavaScript ??
-
Abel, I'm afraid there is a basic understanding of web technologies that you lack. Let's make this as simple as possible.
What are you trying to do?
-
Yes you can, but why do you want to use Serverside JavaScript?
Please explain!
Assumedly, using Javascript on the server, will give you the same handicap. The Request object is approachable with any valid serverside language, but not from the client without making a new call. Like Monte96 said, any serverside processing happens before the HTML is sent to the browser.
-
I know that I'm not that good at writing asp-code.
I have a page with a textbox and a submit-button.
The user writes his name in the box and press the button. Then a new page will be loaded which says "Hi James" (if he filled in James in the textbox)
I have made this using VbScript, but couldn't do it using JavaScript.
Can it be done ??
-
I would imagine it can.
Now do you realize that this will be using server-side JavaScript, and not client-side JavaScript?
If so, then go to developer.netscape.com and look for the documentation on server-side JavaScript.
Are you moving away from ASPs?
-
Is this what you want?
Code:
<script language="javascript">
Function checkUser()
{
var1 = "<%=request.form("txtUser")%>"
if (va1!="")
alert("Hi " + var1);
}
</script>
-
Well, I'm trying to build an own community (very small), just to see if I can make it. I build one using VBScript, but since you must have Explorer then I wanted to build it in some other language and thought of JavaScript.
-
Client side VBScript only works with Internet Explorer BUT ASP works server side so it works with any browser. The ASP interpreter (not sure if this the corrent word in this case ;) ) takes the ASP source code and displays it as HTML. Thats why you take a look at the source code, in a browser, in any ASP page, it displays it as HTML and not your ASP code.
If you really want to try another language try installing PHP and learning a bit of that, its similar to ASP, but has similar syntax to Javascript.
You might have a bit of luck with server-side Javascript but I recommend staying away from it.
-
-
ASP supports JScript, which is Microsoft's "interpretation" of javascript, so you could do that if you like javascript syntax better than VBScript syntax.