473,320 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need to return string and write generic script

<disclaimer>js newbie</disclaimer>

My page has a form comprised of several radio buttons. I want to poll the
buttons to determine which button was selected and convert its value to a
string. I then want to use the string on the same page.

My script is:

function checkRadio(field) {
for(var i=0; i < field.length; i++) {
if(field[i].checked) return field[i].value;
}
return false;
}
function checkFormLeft()
{
if(radioValue = checkRadio(form1.p1_p6_left)) {
if (radioValue == 0) {$syml = 'Uniform Thermal Pattern';}
if (radioValue == 10) {$syml = 'regular thermovascular pattern';}
if (radioValue == 20) {$syml = 'thermovascular network';}
if (radioValue == 25) {$syml = 'irregular thermovascular
pattern';}
if (radioValue == 40) {$syml = 'distorted thermovascular
pattern';}
if (radioValue == 60) {$syml = 'anarchic thermovascular pattern';}
alert("You selected " + $syml);
}
}

I call the script using onClick="checkForm()"

I added the alerts so I could verify the script is working. It is, but
when I try to use either $syml on the page calling the script, I get
nothing, e.g., 'The veins are $syml.' gives me 'The veins are.'

How do I use the string?

Question 2:

I have several pages with multiple radio (and checkbox) arrays. I'd like
to use a single js script for all of them. The 'p1_p6_left' in the above
is the common name of the radio button array. How do I write
'checkRadio(form1.p1_p6_left)' so I can pass different values in place of
p1_p6_left?

TIA (again)

--
Ed Jay (remove M to respond by email)
Dec 5 '05 #1
18 2231
Ed Jay wrote on 05 dec 2005 in comp.lang.javascript:
<disclaimer>js newbie</disclaimer>
[..]
if (radioValue == 60) {$syml = 'anarchic thermovascular pattern';}


"$syml" what langiage is that?
Not clientside Javascript surely?

Could it be,
that you try to set a serverside [php?] variable on the client?

If so, remember that the server is another machine.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Dec 5 '05 #2

Ed Jay wrote:
<disclaimer>js newbie</disclaimer>

My page has a form comprised of several radio buttons. I want to poll the
buttons to determine which button was selected and convert its value to a
string. I then want to use the string on the same page.

My script is:

function checkRadio(field) {
for(var i=0; i < field.length; i++) {
if(field[i].checked) return field[i].value;
}
return false;
}
function checkFormLeft()
{
if(radioValue = checkRadio(form1.p1_p6_left)) {
if (radioValue == 0) {$syml = 'Uniform Thermal Pattern';}
if (radioValue == 10) {$syml = 'regular thermovascular pattern';}
if (radioValue == 20) {$syml = 'thermovascular network';}
if (radioValue == 25) {$syml = 'irregular thermovascular
pattern';}
if (radioValue == 40) {$syml = 'distorted thermovascular
pattern';}
if (radioValue == 60) {$syml = 'anarchic thermovascular pattern';}
alert("You selected " + $syml);
}
}


Values are always a string, but you're checking against a number.
Also, it would look better if you used a switch statement instead when
you're doing a lot of "ifs". For example:

switch(radioValue)
{
case "0":
$syml = "Uniform Thermal Pattern";
break;
case "10":
$syml = "thermovascular network";
break;
...[add more cases]...
default:
$syml = "none of the above";
break;
}

Dec 5 '05 #3

Evertjan. wrote:
"$syml" what langiage is that?
Not clientside Javascript surely?


Yes, javascript does allow the use of '$' as an identifier. But as you
said, it can potentially become confusing to differentiate between
javascript and php.

Dec 5 '05 #4
"Evertjan." <ex**************@interxnl.net> wrote:
Ed Jay wrote on 05 dec 2005 in comp.lang.javascript:
<disclaimer>js newbie</disclaimer>
[..]
if (radioValue == 60) {$syml = 'anarchic thermovascular pattern';}


"$syml" what langiage is that?
Not clientside Javascript surely?


It's only a label that I assigned.
Could it be,
that you try to set a serverside [php?] variable on the client?
No.
If so, remember that the server is another machine.


Yes, I know. Thanks.

--
Ed Jay (remove M to respond by email)
Dec 5 '05 #5
"web.dev" <we********@gmail.com> wrote:

Ed Jay wrote:
<disclaimer>js newbie</disclaimer>

My page has a form comprised of several radio buttons. I want to poll the
buttons to determine which button was selected and convert its value to a
string. I then want to use the string on the same page.

My script is:

function checkRadio(field) {
for(var i=0; i < field.length; i++) {
if(field[i].checked) return field[i].value;
}
return false;
}
function checkFormLeft()
{
if(radioValue = checkRadio(form1.p1_p6_left)) {
if (radioValue == 0) {$syml = 'Uniform Thermal Pattern';}
if (radioValue == 10) {$syml = 'regular thermovascular pattern';}
if (radioValue == 20) {$syml = 'thermovascular network';}
if (radioValue == 25) {$syml = 'irregular thermovascular
pattern';}
if (radioValue == 40) {$syml = 'distorted thermovascular
pattern';}
if (radioValue == 60) {$syml = 'anarchic thermovascular pattern';}
alert("You selected " + $syml);
}
}
Values are always a string, but you're checking against a number.


I'm checking a number so I can assign the appropriate string. I don't get
your point.
Also, it would look better if you used a switch statement instead when
you're doing a lot of "ifs". For example:

switch(radioValue)
{
case "0":
$syml = "Uniform Thermal Pattern";
break;
case "10":
$syml = "thermovascular network";
break;
...[add more cases]...
default:
$syml = "none of the above";
break;
}

Thanks for the tip, but I still need my two questions answered.

--
Ed Jay (remove M to respond by email)
Dec 5 '05 #6
web.dev wrote on 05 dec 2005 in comp.lang.javascript:
[..]
Values are always a string, but you're checking against a number.
Also, it would look better if you used a switch statement instead when
you're doing a lot of "ifs". For example:

switch(radioValue)
{
case "0":


Or use an array:

<script type='text/javascript'>

var s= [
'Uniform Thermal Pattern',
'regular thermovascular pattern',
'thermovascular network',
'irregular thermovascular pattern',
'distorted thermovascular pattern',
'anarchic thermovascular pattern'
]

function checkRadio(field) {
for(var i=0; i < field.length; i++)
if(field[i].checked)
alert('You selected:\n' + s[i]);
return false;
}

</script>

<form onsubmit='return checkRadio(this.r1)'>
<input type='radio' name='r1'>0
<input type='radio' name='r1'>10
<input type='radio' name='r1'>20
<input type='radio' name='r1'>25
<input type='radio' name='r1'>40
<input type='radio' name='r1'>60
<input type='submit'>
</form>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Dec 5 '05 #7

Ed Jay wrote:
"web.dev" <we********@gmail.com> wrote:

Values are always a string, but you're checking against a number.


I'm checking a number so I can assign the appropriate string. I don't get
your point.


Following your style of programming, if I were to do what you were
doing, it would instead be this:

if(radioValue == "0")
....
else if(radio Value == "10")
....

The values you you get from the fields are *strings* not a number.
Therefore, checking against a number will not work. You need to check
against another string value.

Dec 5 '05 #8
"web.dev" <we********@gmail.com> wrote:

Ed Jay wrote:
"web.dev" <we********@gmail.com> wrote:
>Values are always a string, but you're checking against a number.


I'm checking a number so I can assign the appropriate string. I don't get
your point.


Following your style of programming, if I were to do what you were
doing, it would instead be this:

if(radioValue == "0")
...
else if(radio Value == "10")


Why use 'else' if it's not needed?...

The values you you get from the fields are *strings* not a number.
Therefore, checking against a number will not work. You need to check
against another string value.


I understand what you're saying, but it seems to be working, except as
noted in my original questions.

My buttons have numerical values, i.e., 'value = 10' not 'value = "10",'
so aren't they numbers I'm checking against?

As I say, except for my original questions, when I click a button, the
alert window comes up with the correct string ($syml).

--
Ed Jay (remove M to respond by email)
Dec 5 '05 #9
Lee <RE**************@cox.net> wrote:
Ed Jay said:

<disclaimer>js newbie</disclaimer>

My page has a form comprised of several radio buttons. I want to poll the
buttons to determine which button was selected and convert its value to a
string. I then want to use the string on the same page.

My script is:

function checkRadio(field) {
for(var i=0; i < field.length; i++) {
if(field[i].checked) return field[i].value;
}
return false;
}
function checkFormLeft()
{
if(radioValue = checkRadio(form1.p1_p6_left)) {
if (radioValue == 0) {$syml = 'Uniform Thermal Pattern';}
if (radioValue == 10) {$syml = 'regular thermovascular pattern';}
if (radioValue == 20) {$syml = 'thermovascular network';}
if (radioValue == 25) {$syml = 'irregular thermovascular
pattern';}
if (radioValue == 40) {$syml = 'distorted thermovascular
pattern';}
if (radioValue == 60) {$syml = 'anarchic thermovascular pattern';}
alert("You selected " + $syml);
}
}

I call the script using onClick="checkForm()"
Obviously that's not really how you're calling checkFormLeft().


:-) You're correct...I call it as checkFormLeft().
Are you calling checkFormLeft() from within a function that
contains "var $syml"?
No. I'm simply calling it with an onClick event from within a form input
element, e.g., <input name=xyz value=25 onClick="checkFormLeft();">
If so, you've declared the variable to
be local to that function, so you can't set its value in another.
If all checkFormLeft() does is set the value of that variable,
have it return that value, rather than assign to a global.


I don't understand. One of my questions was 'how do I return the variable
so I can use it on the calling page?'

--
Ed Jay (remove M to respond by email)
Dec 5 '05 #10
Ed Jay wrote:
<disclaimer>js newbie</disclaimer>

My page has a form comprised of several radio buttons. I want to poll the
buttons to determine which button was selected and convert its value to a
string. I then want to use the string on the same page.

My script is:

function checkRadio(field) {
for(var i=0; i < field.length; i++) {
if(field[i].checked) return field[i].value;
}
return false;
There is no need to return false.

}
function checkFormLeft()
{
if(radioValue = checkRadio(form1.p1_p6_left)) {
If the value of 'radioValue' is ever set to zero, this assignment/test
will fail and your script will not run.

if (radioValue == 0) {$syml = 'Uniform Thermal Pattern';}
If all you want to do is return the string 'Uniform ...', then:

if (radioValue == 0) {return 'Uniform Thermal Pattern';}

But as Evertjan suggested, the values are much better off in an array
or object and you can ditch all those conditional statements.

if (radioValue == 10) {$syml = 'regular thermovascular pattern';}
if (radioValue == 20) {$syml = 'thermovascular network';}
if (radioValue == 25) {$syml = 'irregular thermovascular
pattern';}
if (radioValue == 40) {$syml = 'distorted thermovascular
pattern';}
if (radioValue == 60) {$syml = 'anarchic thermovascular pattern';}
alert("You selected " + $syml);
}
}

Then have a function that writes the value to the page:

function writeButtonValue(elementID)
{
var txt = checkFormLeft();
document.getElementById(elementID).innerHTML = txt;
}

Instead of calling checkFormLeft from the page, call writeButtonValue
and pass it the ID of the element you want to write the value into.

I call the script using onClick="checkForm()"

I added the alerts so I could verify the script is working. It is, but
when I try to use either $syml on the page calling the script, I get
nothing, e.g., 'The veins are $syml.' gives me 'The veins are.'
Because you created $sml as a local variable within checkFormLeft so
it is not accessible to functions outside checkFormLeft.


How do I use the string?

Question 2:

I have several pages with multiple radio (and checkbox) arrays. I'd like
to use a single js script for all of them. The 'p1_p6_left' in the above
is the common name of the radio button array. How do I write
'checkRadio(form1.p1_p6_left)' so I can pass different values in place of
p1_p6_left?


Pass it from the onclick:

onclick="checkForm('p1_p6_left');"
And then checkFormLeft becomes:

function checkFormLeft( butSet )
{
if(radioValue = checkRadio(form1[butSet])) {
...
}

Or if you use the suggested writeButtonValue, pass an element ID and
the button set name:
onclick="writeButtonValue('elementID','p1_p6_left' );"
function writeButtonValue(elementID, elementName)
{
var txt = checkFormLeft(elementName);
document.getElementById(elementID).innerHTML = txt;
}

--
Rob
Dec 5 '05 #11
RobG <rg***@iinet.net.auau> wrote:
Ed Jay wrote:
<disclaimer>js newbie</disclaimer>

My page has a form comprised of several radio buttons. I want to poll the
buttons to determine which button was selected and convert its value to a
string. I then want to use the string on the same page.

My script is:

function checkRadio(field) {
for(var i=0; i < field.length; i++) {
if(field[i].checked) return field[i].value;
}
return false;
There is no need to return false.

}
function checkFormLeft()
{
if(radioValue = checkRadio(form1.p1_p6_left)) {


If the value of 'radioValue' is ever set to zero, this assignment/test
will fail and your script will not run.

if (radioValue == 0) {$syml = 'Uniform Thermal Pattern';}


If all you want to do is return the string 'Uniform ...', then:

if (radioValue == 0) {return 'Uniform Thermal Pattern';}


I want to be able to use the string in text in multiple places on the
page. Using 'return 'string' do I call the script each time I want to use
the string?
But as Evertjan suggested, the values are much better off in an array
or object and you can ditch all those conditional statements.

if (radioValue == 10) {$syml = 'regular thermovascular pattern';}
if (radioValue == 20) {$syml = 'thermovascular network';}
if (radioValue == 25) {$syml = 'irregular thermovascular
pattern';}
if (radioValue == 40) {$syml = 'distorted thermovascular
pattern';}
if (radioValue == 60) {$syml = 'anarchic thermovascular pattern';}
alert("You selected " + $syml);
}
}

Then have a function that writes the value to the page:

function writeButtonValue(elementID)
{
var txt = checkFormLeft();
document.getElementById(elementID).innerHTML = txt;
}

Instead of calling checkFormLeft from the page, call writeButtonValue
and pass it the ID of the element you want to write the value into.

I call the script using onClick="checkForm()"

I added the alerts so I could verify the script is working. It is, but
when I try to use either $syml on the page calling the script, I get
nothing, e.g., 'The veins are $syml.' gives me 'The veins are.'


Because you created $sml as a local variable within checkFormLeft so
it is not accessible to functions outside checkFormLeft.


How do I use the string?

Question 2:

I have several pages with multiple radio (and checkbox) arrays. I'd like
to use a single js script for all of them. The 'p1_p6_left' in the above
is the common name of the radio button array. How do I write
'checkRadio(form1.p1_p6_left)' so I can pass different values in place of
p1_p6_left?


Pass it from the onclick:

onclick="checkForm('p1_p6_left');"
And then checkFormLeft becomes:

function checkFormLeft( butSet )
{
if(radioValue = checkRadio(form1[butSet])) {
...
}


Thanks.
Or if you use the suggested writeButtonValue, pass an element ID and
the button set name:
onclick="writeButtonValue('elementID','p1_p6_left' );"
function writeButtonValue(elementID, elementName)
{
var txt = checkFormLeft(elementName);
document.getElementById(elementID).innerHTML = txt;
}


I don't want to assign the resulting $syml to a button. I want to use it
several places on the page.

--
Ed Jay (remove M to respond by email)
Dec 5 '05 #12
Lee <RE**************@cox.net> wrote:
Ed Jay said:

Lee <RE**************@cox.net> wrote:
Ed Jay said:

<disclaimer>js newbie</disclaimer>

My page has a form comprised of several radio buttons. I want to poll the
buttons to determine which button was selected and convert its value to a
string. I then want to use the string on the same page.

My script is:

function checkRadio(field) {
for(var i=0; i < field.length; i++) {
if(field[i].checked) return field[i].value;
}
return false;
}
function checkFormLeft()
{
if(radioValue = checkRadio(form1.p1_p6_left)) {
if (radioValue == 0) {$syml = 'Uniform Thermal Pattern';}
if (radioValue == 10) {$syml = 'regular thermovascular pattern';}
if (radioValue == 20) {$syml = 'thermovascular network';}
if (radioValue == 25) {$syml = 'irregular thermovascular
pattern';}
if (radioValue == 40) {$syml = 'distorted thermovascular
pattern';}
if (radioValue == 60) {$syml = 'anarchic thermovascular pattern';}
alert("You selected " + $syml);
}
}

I call the script using onClick="checkForm()"

Obviously that's not really how you're calling checkFormLeft().
:-) You're correct...I call it as checkFormLeft().
Are you calling checkFormLeft() from within a function that
contains "var $syml"?


No. I'm simply calling it with an onClick event from within a form input
element, e.g., <input name=xyz value=25 onClick="checkFormLeft();">
If so, you've declared the variable to
be local to that function, so you can't set its value in another.
If all checkFormLeft() does is set the value of that variable,
have it return that value, rather than assign to a global.


I don't understand. One of my questions was 'how do I return the variable
so I can use it on the calling page?'


My question was based on the assumption that checkFormLeft() is actually
called from checkForm().


Sorry, I misunderstood your question's intent.
How are you trying to use the variable? Remember that it won't have any
value until you click whatever button it is that calls your function.
Pressing any one of the first set of radio buttons brings up a menu of
checkboxes. Checking one or more of the checkboxes will bring up another
set of checkboxes. I'll call the checkFormLeft() function (or equivalent)
from the set of radio buttons. I then plan to use the resulting string
($syml) as part of the text for the first and second checkbox menus. The
title might look something like:

'Choose the regions in which the $syml is observed, then measure the
temperature of the $syml.'
Also, if you want your code to work in any browser other than Internet
Explorer, you should change "checkRadio(form1.p1_p6_left)" to
"checkRadio(document.form1.p1_p6_left)". Most browsers don't allow you
to refer to forms directly.
Thank you.
The following works:

<html>
<head>
<script type="text/javascript">
function checkRadio(field) {
for(var i=0; i < field.length; i++) {
if(field[i].checked) return field[i].value;
}
return false;
}
function checkFormLeft()
{
if(radioValue = checkRadio(document.form1.p1_p6_left)) {
// Note that I changed that to "document..." for browsers
// other than Internet Explorer
if (radioValue == 0) {$syml = 'Uniform Thermal Pattern';}
if (radioValue == 10) {$syml = 'regular thermovascular pattern';}
if (radioValue == 20) {$syml = 'thermovascular network';}
if (radioValue == 25) {$syml = 'irregular thermovascular pattern';}
if (radioValue == 40) {$syml = 'distorted thermovascular pattern';}
if (radioValue == 60) {$syml = 'anarchic thermovascular pattern';}
alert("You selected " + $syml);
}
}
</script>
</head>
<body>
<form name="form1">
0<input type="radio" value="0" name="p1_p6_left"><br>
10<input type="radio" value="10" name="p1_p6_left"><br>
20<input type="radio" value="20" name="p1_p6_left"><br>
25<input type="radio" value="25" name="p1_p6_left"><br>
40<input type="radio" value="40" name="p1_p6_left"><br>
60<input type="radio" value="60" name="p1_p6_left"><br>
<input type="button" onclick="checkFormLeft()" value="checkFormLeft()">
<br>
<input type="button" onclick="alert($syml)" value="alert($syml)">
</form>
</body>
</html>


Here's where I am--my code is now:

var s= [
'Uniform Thermal Pattern',
'regular thermovascular pattern',
'thermovascular network',
'irregular thermovascular pattern',
'distorted thermovascular pattern',
'anarchic thermovascular pattern'
]

function checkRadio(field) {
for(var i=0; i < field.length; i++)
if(field[i].checked)
alert(s[i]);
return false;
}

Calling it with onClick = "checkRadio(p1_p6.left)";

Once again, this works fine to the extent that the alerts show the
appropriate string; however, I still don't know how to use the result on
the calling page. I'm also going to want to pass the result to a cgi form
using a hidden input element.

(BTW, I say 'the calling page' because the js is remotely linked to the
page. I have several pages that want to use the same script, but with
different field names.)

Is it possible to use the above function with checkboxes instead of radio
buttons?

What if the field names aren't the same, but are serialized? For example,
say the checkboxes are named p1_p6_left_1, p1_p6_left_2...?

--
Ed Jay (remove M to respond by email)
Dec 6 '05 #13
Lee <RE**************@cox.net> wrote:
Ed Jay said:
I don't want to assign the resulting $syml to a button. I want to use it
several places on the page.
What do you mean by using it several places on the page?

First the entire page will be displayed.
Yes.
Then the user will select a radio box.
When the user selects a radio button, it displays a hidden menu of
checkboxes. I want this second menu to use the string result ($syml) in
the menu title and elsewhere.
Then the user will click a button.
From the second menu of checkboxes.
Then the value will be available.
I don't understand you.
What do you want to happen?


I want the value to be used to label the second menu and to be passed to
another form (page 2) using a hidden input element.

On the theory that one picture is worth a few words... Please go to
<http://www.edbj.aes-intl.com/cgi-bin/brca_mod13.pl>. On the menu "For
Each Breast, Select the venous Pattern Observed," click on "Anarchic
Thermovascular Pattern." An alert will pop up confirming that the js is
working. Note the (cyan) menu that appears at the bottom of the page. Note
that s[i] in the text? That's where I want the resulting string to appear
(as well as the hidden input element).

--
Ed Jay (remove M to respond by email)
Dec 6 '05 #14
Lee <RE**************@cox.net> wrote:
Ed Jay said:
On the theory that one picture is worth a few words... Please go to
<http://www.edbj.aes-intl.com/cgi-bin/brca_mod13.pl>. On the menu "For
Each Breast, Select the venous Pattern Observed," click on "Anarchic
Thermovascular Pattern." An alert will pop up confirming that the js is
working. Note the (cyan) menu that appears at the bottom of the page. Note
that s[i] in the text? That's where I want the resulting string to appear
(as well as the hidden input element).


At a glance, the problem may be as simple as the fact that you've
got your onclick handler defined to show the menu, and *then* check
to see which radio button is checked.

Try changing each occurance of:
onclick="show('div1');checkRadio(p1_p6_left);"
to:
onclick="checkRadio(p1_p6_left);show('div1');"


Doh! That wasn't the solution, but it's sure was a stupid error. :-)

Thanks for looking.

If I understand correctly, the value that is returned as $syml (or s[i] as
in my alternate attempt that didn't work either) is only known internally
to the function. Does my question then morph to 'how do I make a local
variable global to the page that called the function?'

I was planning to score the sum of multiple-checked boxes with the
following. How do I use 'score' outside of the function? I think that's
essentially one of the same questions I've been asking.

var score;
function checkRadio(field) {
for(var i=0; i < field.length; i++) {
score = (score + if(field[i].checked) return field[i].value);
}
}

--
Ed Jay (remove M to respond by email)
Dec 6 '05 #15
Ed Jay wrote:
"web.dev" <we********@gmail.com> wrote:
Ed Jay wrote:
"web.dev" <we********@gmail.com> wrote:
Values are always a string, but you're checking against a number.
I'm checking a number so I can assign the appropriate string. I don't get
your point. Following your style of programming, if I were to do what you were
doing, it would instead be this:

if(radioValue == "0")
...
else if(radio Value == "10")


Why use 'else' if it's not needed?


Because it's a waste of time to look to see whether something is equal
to "10" if you already know that it's equal to "0", and if you don't put
that "else" there, that's what the computer is going to do.
My buttons have numerical values, i.e., 'value = 10' not 'value = "10",'
so aren't they numbers I'm checking against?


No, your buttons have string values. They may happen to be strings that
are numbers, but they're still strings, because that's how HTML buttons
work. In order to compare "10" to 10, the computer has to do extra work.
(In a less forgiving language, in fact, you'd simply get an error
message that you are trying to compare apples and oranges, and your
program would stop dead.)

--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"
Dec 6 '05 #16
web.dev wrote:
Evertjan. wrote:
"$syml" what langiage is that?
Not clientside Javascript surely?


Yes, javascript does allow the use of '$' as an identifier. But as you
said, it can potentially become confusing to differentiate between
javascript and php.


Or other programming languages, for that matter.
PointedEars
Dec 7 '05 #17
Thomas 'PointedEars' Lahn wrote on 07 dec 2005 in comp.lang.javascript:
web.dev wrote:
Evertjan. wrote:
"$syml" what langiage is that?
Not clientside Javascript surely?


Yes, javascript does allow the use of '$' as an identifier. But as you
said, it can potentially become confusing to differentiate between
javascript and php.


Or other programming languages, for that matter.


I'm glad you agree.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Dec 7 '05 #18
Ed Jay wrote:

<disclaimer>js newbie</disclaimer>

After a day of learning, thank you, I have my situation down to...

The code:

var s= [
'Uniform Thermal Pattern',
'regular thermovascular pattern',
'thermovascular network',
'irregular thermovascular pattern',
'distorted thermovascular pattern',
'anarchic thermovascular pattern'
]

function checkRadio(field) {
for(var i=0; i < field.length; i++)
if(field[i].checked) {
return s[i];
}
s[i] = 'undefined pattern';
return s[i];
}

The function passes the common name of a set of radio buttons. It is
called from within a hidden container before the hidden container is made
visible. The container's visibility is toggled by whichever radio button
is checked. I have confirmed that the function works. I have also
confirmed that the inline script i=3; document.write(s[i]); writes the
correctly indexed array.

But...

When placed within html text at the position I want to publish the
selected and indexed phrase, the inline script
'document.write(checkRadio(field);' displays nothing. Neither does
'checkRadio(field); document.write(s[i]) never makes it past the
document.write() statement, at least other js-driven events stopped
executing.

It occurs to me that the only time my inline function is called is when
the page loads.

--
Ed Jay (remove M to respond by email)
Dec 8 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
10
by: Nikita A. Visnevski | last post by:
Hi everyone, I am rather new to Java beans. Just picked up a book last night and started reading about them. I am building an application that allows a user to define objects with dynamic...
2
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server...
7
by: Jack Addington | last post by:
I've got a fairly simple application implementation that over time is going to get a lot bigger. I'm really trying to implement it in a way that will facilitate the growth. I am first writing a...
3
by: Sky Sigal | last post by:
I coming unglued... really need some help. 3 days chasing my tail all over MSDN's documentation ...and I'm getting nowhere. I have a problem with TypeConverters and storage of expandableobjects...
0
by: Miguel Dias Moura | last post by:
Hello, I am saving a complex type in Asp.Net 2.0 profile. I am using an SQL 2005 database as a profile provider. I have been consulting MSDN as help to create my class. (Please, see my code...
1
by: jens Jensen | last post by:
Hello , i'm calling a webservice generated with oracle webservice java tools. I'm not able to add a web reference to a .net client the usual way with visual studio 2005. I was therefore...
8
by: pamelafluente | last post by:
I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work. This is what I need to accomplish: ---------------------- Given button and a TextBox on a...
1
by: shapper | last post by:
Hello, I created a user control (.ascx) with a property as follows: Private _Messages As Generic.List(Of String) Public Property Messages() As Generic.List(Of String) Get Return _Messages...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.