473,383 Members | 1,813 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,383 software developers and data experts.

strings..

var myform= document.formPricing;
var one = "price";
alert(one);

var amount = myform.one.value;

the alert prints name of element fine, however, on line

var amount = myform.one.value;

I get error 'one.value is null or not an obj'... (and element is not
empty..) I don't get this.. thank you...
Sep 27 '05 #1
6 1213

Be more precise and specific or paste your relevant code for us to see what
you have.

Danny
Sep 27 '05 #2
Frances Del Rio wrote:
var myform= document.formPricing;
var one = "price";
alert(one);

var amount = myform.one.value;

the alert prints name of element fine, however, on line

var amount = myform.one.value;

I get error 'one.value is null or not an obj'... (and element is not
empty..) I don't get this.. thank you...

disregard pls -- had to do:

eval('myform.' + one + '.value');

Sep 27 '05 #3
Without knowing exactly what you're up to, i can't be sure, but for
most every case i've seen, you can do

myform['one'].value

which doesn't rely so heavily on eval, which, while a powerful tool,
isn't always necessary and can often be replaced with something more
mundane if you look for some alternate syntax. :)

-Brendan

Sep 27 '05 #4

Frances Del Rio wrote:
var myform= document.formPricing;
var one = "price";
alert(one);

var amount = myform.one.value;

the alert prints name of element fine, however, on line

var amount = myform.one.value;

I get error 'one.value is null or not an obj'... (and element is not
empty..) I don't get this.. thank you...


It appears you don't understand how to access form elements.

To do what you wanted to as above then you should've done it like so:

myform.price.value

I prefer to do it this way:

document.forms["form name"].elements["form element name"]

Sep 27 '05 #5
On 27/09/2005 22:52, Donius wrote:

[snip]
myform['one'].value


If one is a variable, which it is supposed to be in the OP, then omit
the quotation marks:

myform[one].value

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Sep 28 '05 #6
Frances Del Rio said the following on 9/27/2005 5:36 PM:
Frances Del Rio wrote:
var myform= document.formPricing;
var one = "price";
alert(one);

var amount = myform.one.value;

the alert prints name of element fine, however, on line

var amount = myform.one.value;

I get error 'one.value is null or not an obj'... (and element is not
empty..) I don't get this.. thank you...


disregard pls -- had to do:

eval('myform.' + one + '.value');


No, you did not have to do that. eval is *not* needed there. 99% of the
uses of eval (if not higher) on the web is the lack of understanding on
the part of the person who wrote it.

myform[one].value;

Look Ma, No eval!

http://jibbering.com/faq/#FAQ4_40

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 28 '05 #7

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

Similar topics

20
by: Ravi | last post by:
Hi, I have about 200GB of data that I need to go through and extract the common first part of a line. Something like this. >>>a = "abcdefghijklmnopqrstuvwxyz" >>>b = "abcdefghijklmnopBHLHT"...
17
by: Gordon Airport | last post by:
Has anyone suggested introducing a mutable string type (yes, of course) and distinguishing them from standard strings by the quote type - single or double? As far as I know ' and " are currently...
16
by: Paul Prescod | last post by:
I skimmed the tutorial and something alarmed me. "Strings are a powerful data type in Prothon. Unlike many languages, they can be of unlimited size (constrained only by memory size) and can hold...
4
by: agent349 | last post by:
First off, I know arrays can't be compared directly (ie: if (arrary1 == array2)). However, I've been trying to compare two arrays using pointers with no success. Basically, I want to take three...
25
by: Rainmaker | last post by:
Hi, Can anyone tell me an efficient algorithm to sort an array of strings? Keep in mind that this array is HUGE and so the algorithm should me efficient enough to deal with it. Thanks
6
by: Broeisi | last post by:
Hello, I wrote the tiny progam below just to understand arrays and strings better. I have 2 questions about arrays and strings in C. 1. Why is it that when you want to assign a string to an...
2
by: Potiuper | last post by:
Question: Is it possible to use a char pointer array ( char *<name> ) to read an array of strings from a file in C? Given: code is written in ANSI C; I know the exact nature of the strings to be...
19
by: pkirk25 | last post by:
I wonder if anyone has time to write a small example program based on this data or to critique my own effort? A file called Realm List.html contains the following data: Bladefist-Horde...
95
by: hstagni | last post by:
Where can I find a library to created text-based windows applications? Im looking for a library that can make windows and buttons inside console.. Many old apps were make like this, i guess ...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.