Here is some sample javascript code to control the content of one dropdown
with the selection in another.
-----Original Message-----
From: JavaScript HowTo digest [mailto:javascript_howto@p...]
Sent: Thursday, March 13, 2003 6:12 PM
To: javascript_howto digest recipients
Subject: javascript_howto digest: March 13, 2003
-----------------------------------------------
When replying to the digest, please quote only
relevant material, and edit the subject line to
reflect the message you are replying to.
-----------------------------------------------
The URL for this list is:
http://p2p.wrox.com/list.asp?list=javascript_howto
JAVASCRIPT_HOWTO Digest for Thursday, March 13, 2003.
1. Help: menu selection to next page of Shopping Cart
2. Help with menu selection to next page of Shopping Cart
3. using mouseover to change a background image
4. Parsing Lines with JavaScript Problem #############
5. RE: using mouseover to change a background image
6. RE: using mouseover to change a background image
7. RE: using mouseover to change a background image
8. Re: DETECT THE ENTER KEY AND CALL A ASP FUNCTION
9. Re: DETECT THE ENTER KEY AND CALL A ASP FUNCTION
----------------------------------------------------------------------
Subject: Help: menu selection to next page of Shopping Cart
From: "Keith Sarver" <keith.sarver@f...>
Date: Thu, 13 Mar 2003 01:45:48
X-Message-Number: 1
I'm designing a site for an online catalogue and have a small
problem. I am using a Javascript Shopping Cart from the
Professional Javascript edition 2 book from wrox, but have made
modifications. I need some help transferring information in a
drop-down menu from one page of the Shopping Cart to the next.
Does anyone know how this may be done? Go to
http://www.stanlowa.com/html/ShoppingCart/StanlowaCommande.ht
ml to see an example. This site is in French, but all you have to do is
make a selection from the Adulte menu to the top right, Tutus, for
example, to see what I mean. Notice that there is a Ref#, name,
description, and Couleur (Color) and Taille (Size) drop-down menus
for each item. Click on a price to add the item to the Shopping Cart. I
need to know how to get the selected Color and Size to the next page.
Is there an easy way to do this document.write, or get & set, or with
Input Hidden?
Thanks in advance, if you need more explanation or to see some
code such as the external .js files, don't hesitate to write.
Keith
----------------------------------------------------------------------
Subject: Help with menu selection to next page of Shopping Cart
From: "Keith Sarver" <keith.sarver@f...>
Date: Thu, 13 Mar 2003 01:48:34
X-Message-Number: 2
Sorry to post twice, but the first attempt didn't post the subject line.
I'm designing a site for an online catalogue and have a small
problem. I am using a Javascript Shopping Cart from the
Professional Javascript edition 2 book from wrox, but have made
modifications. I need some help transferring information in a
drop-down menu from one page of the Shopping Cart to the next.
Does anyone know how this may be done? Go to
http://www.stanlowa.com/html/ShoppingCart/StanlowaCommande.ht
ml to see an example. This site is in French, but all you have to do is
make a selection from the Adulte menu to the top right, Tutus, for
example, to see what I mean. Notice that there is a Ref#, name,
description, and Couleur (Color) and Taille (Size) drop-down menus
for each item. Click on a price to add the item to the Shopping Cart. I
need to know how to get the selected Color and Size to the next page.
Is there an easy way to do this document.write, or get & set, or with
Input Hidden?
Thanks in advance, if you need more explanation or to see some
code such as the external .js files, don't hesitate to write.
Keith
----------------------------------------------------------------------
Subject: using mouseover to change a background image
From: "Harpreet" <harpreet@c...>
Date: Wed, 12 Mar 2003 23:38:45 -0500
X-Message-Number: 3
List members,
I am using the following to change my background image when I mouse over a
table cell. But it does not work. What am I missing.
<td nowrap align="middle" width="93"
background="../images/tab_off_devices.gif" height="24"
onmouseover="chkVer('go3','but5')" onmouseout="chkVer('go3','but4')"
name="go3"></td>
Please help,
Thanks
----------------------------------------------------------------------
Subject: Parsing Lines with JavaScript Problem #############
From: "Patrick Noel Mc Govern" <gopat@n...>
Date: Thu, 13 Mar 2003 05:30:33
X-Message-Number: 4
Hi,
I am trying to create a JavaScript program that will allow a
user to paste/type text into a text area box. When the user
clicks on a button the JavaScript code will store each line
into an array to allow specific logic to alter the text and
display the results in the output text area box.
The sample html/JavaScript below will give an idea of my program.
When you put text with blank lines in the top box the output
text will show commas. This is bad.
Does any one have a solution to allow the program to copy text
without the commas that result from blank lines??
Thanks
<HTML>
<HEAD>
<TITLE>HowPage Validation & Document Creator</TITLE>
<SCRIPT LANGUAGE=JavaScript>
function testFunction(){
get_text(document.form1.text_area1, document.form1.text_area2)
}
//This is the main function that puts the input text into an array,
//then the other functions are called from here.
function get_text(text_input, text_output) {
var all_lines = new Array();
var tmp_lines = new Array();
//var all_lines = text_input.value.split('\n'); //Bad: Inserts commas
var all_lines = text_input.value.split('\n\r'); //Works for Linux, Not
windows...
//Add a new line character at the end of each line.
//Proccess each line, then send each task to a function:
for (line_nbr in all_lines)
{
// alert('line_nbr is ' + line_nbr);
// alert('all_lines[line_nbr] ' + all_lines[line_nbr]);
if (line_nbr < all_lines.length)
{
//This stores the above array to a new array with a line break.
//It is broken becuase the first character of each BLANK line
is a comma. ;-(
tmp_lines[line_nbr] = all_lines[line_nbr] + '\n';
}
// alert('tmp_lines[line_nbr] is ' + tmp_lines[line_nbr]);
}
text_output.value = tmp_lines;
}
// End of Main function###############################
</SCRIPT></HEAD>
<BODY>
<TABLE CELLSPACING=0 CELLSPACING="0" WIDTH="550" align="center"
BGCOLOR="white" BORDER="0" >
<!--- BEGIN USER INPUT/OUTPUT FORM SECTION: -->
<FORM NAME="form1">
<H2>JavaScript Parse Line Code Test</H2>
Type your input text in the box below, include some blank lines:
<P>
<!--- User TextArea input box: User pastes contents of text file here.-->
<TEXTAREA NAME="text_area1" ROWS="10" COLS="75" WRAP=VIRTUAL>
</TEXTAREA>
<P>
After clicking the left button, the above text should appear exactly the
same below.
<P>
<!--- Create Out Put Page Button: -->
<BR>
<INPUT TYPE="button" VALUE="Create OutPut Text"
ONCLICK="testFunction()"
>
<!--- Reset User TextArea input box: -->
<INPUT TYPE="reset" VALUE="Reset This Page">
<!--- Output HTML code to this TextArea box: select text button on top -->
<input type=button value="Highlight All Text"
onClick="javascript:document.form1.text_area2.focus();
document.form1.text_area2.select();">
<TEXTAREA NAME="text_area2" ROWS="10" COLS="90" WRAP=VIRTUAL>
</TEXTAREA>
<BR>
</FORM>
</BODY>
</HTML>
----------------------------------------------------------------------
Subject: RE: using mouseover to change a background image
From: "Robert Nyman" <robert.nyman@c...>
Date: Thu, 13 Mar 2003 08:25:42 +0100
X-Message-Number: 5
Please supply the JavaScript code in the chkVer() function.
/Robert
-----Original Message-----
From: Harpreet [mailto:harpreet@c...]
Sent: den 13 mars 2003 05:39
To: JavaScript HowTo
Subject: [javascript_howto] using mouseover to change a background image
List members,
I am using the following to change my background image when I mouse over
a table cell. But it does not work. What am I missing.
<td nowrap align=3D"middle" width=3D"93"
background=3D"../images/tab_off_devices.gif" height=3D"24"
onmouseover=3D"chkVer('go3','but5')" onmouseout=3D"chkVer('go3','but4')"
name=3D"go3"></td>
Please help,
Thanks
----------------------------------------------------------------------
Subject: RE: using mouseover to change a background image
From: "Harpreet" <harpreet@c...>
Date: Thu, 13 Mar 2003 10:37:11 -0500
X-Message-Number: 6
I got this code from the internet. It was used to change the image of an
<image tag using
<table><tr><td onmouseover="chkVer('go3','but5')"
onmouseout="chkVer('go3','but4')"> <img NAME="go3" border="0"
SRC="images\tab_off_devices.gif" WIDTH="93" HEIGHT="24"></td></tr></table>
The above works.
But i want to use the above to change my background image . How can i do
this pleas ehelp.
<SCRIPT language="javascript1.1">
if( document.images )
{
but4=new Image(344,120)
but4.src="tab_off_devices.gif"
but5=new Image(344,120)
but5.src="tab_on_devices.gif"
}
</script>
<script>
<!--
function chkVer(imagename,objectsrc)
{
var n=navigator.appName
var v=parseInt(navigator.appVersion)
var browsok=((n=="Netscape")&&(v>=3))
var browsok2=((n=="Microsoft Internet Explorer")&&(v>=4))
if ((browsok)||(browsok2))
document.images[imagename].src=eval(objectsrc+".src")
}
//-->
</script>
thanks.
----- Original Message -----
From: "Robert Nyman" <robert.nyman@c...>
To: "JavaScript HowTo" <javascript_howto@p...>
Sent: Thursday, March 13, 2003 2:25 AM
Subject: [javascript_howto] RE: using mouseover to change a background image
Please supply the JavaScript code in the chkVer() function.
/Robert
-----Original Message-----
From: Harpreet [mailto:harpreet@c...]
Sent: den 13 mars 2003 05:39
To: JavaScript HowTo
Subject: [javascript_howto] using mouseover to change a background image
List members,
I am using the following to change my background image when I mouse over
a table cell. But it does not work. What am I missing.
<td nowrap align="middle" width="93"
background="../images/tab_off_devices.gif" height="24"
onmouseover="chkVer('go3','but5')" onmouseout="chkVer('go3','but4')"
name="go3"></td>
Please help,
Thanks
----------------------------------------------------------------------
Subject: RE: using mouseover to change a background image
From: "Robert Nyman" <robert.nyman@c...>
Date: Thu, 13 Mar 2003 16:39:47 +0100
X-Message-Number: 7
Ok...
Well, I'll give you code for an easy solution here.
<script>
function changeImg(oElm, strSrc){
oElm.background =3D strSrc;
}=09
</script>
<table>
<tr>
<td onmouseover=3D"changeImg(this,
'yourMouseOverImg.gif')" onmouseout=3D"changeImg(this, 'yourImg.gif')">
Your content
</td>
</tr>
</table>
/Robert
-----Original Message-----
From: Harpreet [mailto:harpreet@c...]
Sent: den 13 mars 2003 16:37
To: JavaScript HowTo
Subject: [javascript_howto] RE: using mouseover to change a background
image
I got this code from the internet. It was used to change the image of an
<image tag using <table><tr><td onmouseover=3D"chkVer('go3','but5')"
onmouseout=3D"chkVer('go3','but4')"> <img NAME=3D"go3" border=3D"0"
SRC=3D"images\tab_off_devices.gif" WIDTH=3D"93"
HEIGHT=3D"24"></td></tr></table>
The above works.
But i want to use the above to change my background image . How can i do
this pleas ehelp.
<SCRIPT language=3D"javascript1.1">
if( document.images )
{
but4=3Dnew Image(344,120)
but4.src=3D"tab_off_devices.gif"
but5=3Dnew Image(344,120)
but5.src=3D"tab_on_devices.gif"
}
</script>
<script>
<!--
function chkVer(imagename,objectsrc)
{
var n=3Dnavigator.appName
var v=3DparseInt(navigator.appVersion)
var browsok=3D((n=3D=3D"Netscape")&&(v>=3D3))
var browsok2=3D((n=3D=3D"Microsoft Internet Explorer")&&(v>=3D4))
if ((browsok)||(browsok2))
document.images[imagename].src=3Deval(objectsrc+".src")
}
//-->
</script>
thanks.
----- Original Message -----
From: "Robert Nyman" <robert.nyman@c...>
To: "JavaScript HowTo" <javascript_howto@p...>
Sent: Thursday, March 13, 2003 2:25 AM
Subject: [javascript_howto] RE: using mouseover to change a background
image
Please supply the JavaScript code in the chkVer() function.
/Robert
-----Original Message-----
From: Harpreet [mailto:harpreet@c...]
Sent: den 13 mars 2003 05:39
To: JavaScript HowTo
Subject: [javascript_howto] using mouseover to change a background image
List members,
I am using the following to change my background image when I mouse over
a table cell. But it does not work. What am I missing.
<td nowrap align=3D"middle" width=3D"93"
background=3D"../images/tab_off_devices.gif" height=3D"24"
onmouseover=3D"chkVer('go3','but5')" onmouseout=3D"chkVer('go3','but4')"
name=3D"go3"></td>
Please help,
Thanks
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to
----------------------------------------------------------------------
Subject: Re: DETECT THE ENTER KEY AND CALL A ASP FUNCTION
From: "Claudio Pallone" <pallone@l...>
Date: Thu, 13 Mar 2003 16:37:45
X-Message-Number: 8
Hi Robert,
What about if I have a collection of querystrings?? Suppose I want to loop
through all the Key/value pair in my querystring since I do not know which
one is being passed and how many?? How do I do that in Javascript?
In ASPX I would somethink like this:
dim i as integer
for i=0 to Request.QueryString.Count-1
xslParams.Add(Request.QueryString.GetKey(i), Request.QueryString.Get(i))
next i
What about in Javascript?
Cheers,
Claudio
> In JavaScript you have to make some string searching...
For instance, to find the value of name:
var strName =3D (location.href.search(/\?name=3D(\w*|\d*)/) !=3D -1)?
location.href.match(/\?name=3D(\w*|\d*)/)[0].replace(/\?name=3D/, "") :
"";
/Robert
-----Original Message-----
From: Claudio Pallone [mailto:pallone@l...]
Sent: den 7 mars 2003 14:16
To: JavaScript HowTo
Subject: [javascript_howto] Re: DETECT THE ENTER KEY AND CALL A ASP
FUNCTION
Hi Robert,
Thanks for your reply.
What I will try to do is to put a button on the page and hide it. Then
when the user clicks the enter key and event will be triggered on the
server, I hope.
I have anoter question. How do I request the querystring in javascript?
in asp I would use Request.Querystring("name")
What about in javascript??
Cheers
Claudio
> Claudio,
You can't call a function on the server from JavaScript code. What you
can do is to post your page with some parameters to=3D20 your ASP page,
and then take action from that.
/Robert
-----Original Message-----
From: Claudio Pallone [mailto:pallone@l...]=3D20
Sent: den 6 mars 2003 17:53
To: JavaScript HowTo
Subject: [javascript_howto] Re: DETECT THE ENTER KEY AND CALL A ASP
FUNCTION
Hi,
I have seen an old post by Robert and was able to use the onKeyPress
=3D3D
13=3D20 to detect when the user press the enter key.
However, I need to be able to call a function on the server when the
user=3D20 press the enter key. I can not figure out how to hook up the
client call
to the server function.
Please could someone help me?
Cheers,
Claudio
> Hi,
I have a text box on a page that allows the user to enter some text (for
=3D3D instance "gin") and then he can click on a button to search the
site
for this word.
However, what I would like to do is to allow the user press the enter
=3D
=3D3D button on the keyboard and then I would call the function and pass
the =3D =3D3D value of the text box.
Many questions arises:
1 - is it possible to detect when the user press the enter key in =3D3D
javascript and then call a function?? If yes, could someone please post
=3D3D some sample code.
2 - if the function is written in ASP, can I still call it using =3D3D
Javascript?
Cheers,
Claudio
BMRB International=3D3D20
http://www.bmrb.co.uk +44 (0)20 8566 5000
____________________________________________________________
This message (and any attachment) is intended only for the recipient and
=3D3D may contain confidential and/or privileged material. If you have
=3D3D
received this in error, please contact the sender and delete this =3D3D
message immediately. Disclosure, copying or other action taken in =3D3D
respect of this email or in reliance on it is prohibited. BMRB =3D3D
International Limited accepts no liability in relation to any personal
=3D
=3D3D emails, or content of any email which does not directly relate to
our =3D =3D3D business.
---
Change your mail options at http://p2p.wrox.com/manager.asp or=3D20 to
unsubscribe send a blank email to
----------------------------------------------------------------------
Subject: Re: DETECT THE ENTER KEY AND CALL A ASP FUNCTION
From: "Robert Nyman" <robert.nyman@c...>
Date: Thu, 13 Mar 2003 17:42:46 +0100
X-Message-Number: 9
I'd really recommend you to use ASP in that case.
But well, the match method returns an array.
So what you have to do is loop through the results from the match
method.
This will probably not work, but to get you in the right direction:
var arrParameters =3D (location.href.search(/(\w+|\d+)=3D(\w*|\d*)/)
!=3D -1)?
location.href.match(/(\w+|\d+)=3D(\w*|\d*)&?/);
for(var i=3D0; i<arrParameters.length; i++){
// Here you have to parse out the keys and their values...
}
/Robert
-----Original Message-----
From: Claudio Pallone [mailto:pallone@l...]
Sent: den 13 mars 2003 17:38
To: JavaScript HowTo
Subject: [javascript_howto] Re: DETECT THE ENTER KEY AND CALL A ASP
FUNCTION
Hi Robert,
What about if I have a collection of querystrings?? Suppose I want to
loop
through all the Key/value pair in my querystring since I do not know
which
one is being passed and how many?? How do I do that in Javascript?
In ASPX I would somethink like this:
dim i as integer
for i=3D0 to Request.QueryString.Count-1
xslParams.Add(Request.QueryString.GetKey(i), Request.QueryString.Get(i))
next i
What about in Javascript?
Cheers,
Claudio
> In JavaScript you have to make some string searching...
For instance, to find the value of name:
var strName =3D3D (location.href.search(/\?name=3D3D(\w*|\d*)/) !=3D3D
-1)?
location.href.match(/\?name=3D3D(\w*|\d*)/)[0].replace(/\?name=3D3D/,
"") :
=3D "";
/Robert
-----Original Message-----
From: Claudio Pallone [mailto:pallone@l...]=3D20
Sent: den 7 mars 2003 14:16
To: JavaScript HowTo
Subject: [javascript_howto] Re: DETECT THE ENTER KEY AND CALL A ASP
FUNCTION
Hi Robert,
Thanks for your reply.
What I will try to do is to put a button on the page and hide it.
Then=3D20 when the user clicks the enter key and event will be triggered
on the=3D20 server, I hope.
I have anoter question. How do I request the querystring in javascript?
in asp I would use Request.Querystring("name")
What about in javascript??
Cheers
Claudio
> Claudio,
You can't call a function on the server from JavaScript code. What you
can do is to post your page with some parameters to=3D3D20 your ASP
page,
and then take action from that.
/Robert
-----Original Message-----
From: Claudio Pallone [mailto:pallone@l...]=3D3D20
Sent: den 6 mars 2003 17:53
To: JavaScript HowTo
Subject: [javascript_howto] Re: DETECT THE ENTER KEY AND CALL A ASP
FUNCTION
Hi,
I have seen an old post by Robert and was able to use the onKeyPress =3D
=3D3D3D 13=3D3D20 to detect when the user press the enter key.
However, I need to be able to call a function on the server when the
user=3D3D20 press the enter key. I can not figure out how to hook up the
client call
to the server function.
Please could someone help me?
Cheers,
Claudio
> Hi,
I have a text box on a page that allows the user to enter some text (for
=3D3D3D instance "gin") and then he can click on a button to search the
=3D
site for this word.
However, what I would like to do is to allow the user press the enter
=3D
=3D3D =3D3D3D button on the keyboard and then I would call the function
and
pass the =3D3D =3D3D3D value of the text box.
Many questions arises:
1 - is it possible to detect when the user press the enter key in
=3D3D3D
javascript and then call a function?? If yes, could someone please post
=3D3D3D some sample code.
2 - if the function is written in ASP, can I still call it using =3D3D3D
Javascript?
Cheers,
Claudio
BMRB International=3D3D3D20
http://www.bmrb.co.uk +44 (0)20 8566 5000
____________________________________________________________
This message (and any attachment) is intended only for the recipient and
=3D3D3D may contain confidential and/or privileged material. If you have
=3D
=3D3D3D received this in error, please contact the sender and delete
this
=3D3D3D message immediately. Disclosure, copying or other action taken
in
=3D3D3D respect of this email or in reliance on it is prohibited. BMRB
=3D3D3D International Limited accepts no liability in relation to any
personal =3D =3D3D =3D3D3D emails, or content of any email which does
not
directly relate to our =3D3D =3D3D3D business.
---
Change your mail options at http://p2p.wrox.com/manager.asp or=3D3D20 to
unsubscribe send a blank email to
---
Change your mail options at http://p2p.wrox.com/manager.asp or=3D20 to
unsubscribe send a blank email to
---
END OF DIGEST