Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie needs help with jscript function.

Status
Not open for further replies.

geojf3

Programmer
Aug 23, 2004
7
US
Hi all,

I have a web page that is written in asp/vbscript. It is used for people in the field to log onto and enter product id's, quantities and location information.

I was asked to change the page, so that when the person types in the product id and tabs to the next field, the product description would show. The only way I could do that was to have the same page re-load after all of the id's were typed in and the user would then click a button and the descriptions would appear.

Poking around, I found the onBlur function and tried to implement that. I finally got that to work, but I came up to two problems.

This is the code for putting the text box on the page :

response.write("<td class=""detaill""><input type=""text""
onChange=""clr()"" name=""txtID_" & x & """ size=""10"" value=" &
Request.Form("txtID_" & x) & "></td>")

x will be a number 1 thru 20, so I can have 20 text boxes on the screen.

The first problem is when I get to the clr() function, how can I know what the field name of the text box is? txtID_1, txtid_2, etc.

Second, the function to connect to the database and retrieve the description is in vbscript. Since I do not know that much about jscript and I need to have this done by the end of this month, is there a way to call a vbscript function from the jscript function?

Thank you for you help.

George
 
You can pass the clr() function the keyword "this". "this" specifies the current object. So, if your clr() function had this line of code:

[tt]
function clr(obj) {
alert(obj.name);
}[/tt]

and call it like this...

[tt]
<input name="tb1" value="something" onChange="clr(this);">
[/tt]

Then, when the textbox changes, an alertbox will popup, showing the textbox's name.

As for calling a vbscript function from javascript - no, there is no way that I know of. Maybe someone will prove me wrong.

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
Thanks for the passing of the text name.

If I cannot call a vbscript function, how then would jscript handle this:

SET CON1=SERVER.CREATEOBJECT("ADODB.CONNECTION")
SET CMD1=SERVER.CREATEOBJECT("ADODB.COMMAND")
CON1.OPEN "DSN=webfiles;UID=webfiles;PWD=webfiles"
CMD1.ACTIVECONNECTION = CON1

Thanks again,

George
 
I am asking, how would I write that vbscript code in jscript.

Thanks,

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top