Urgent problem, repeat, Urgent problem.

R

Rob

I have a form - when you click the submit button, it appends a
variable to the URL (e.g. xyz.cgi?inputID=some_dynamic_variable)

It also opens a new page. Now, that some_dynamic_variable is actually
the name of a form element on the parent window.

On the new page, I have this javascript:
----
var var2 = location.search.substring(9);
document.write(var2)
----
This will print out some_dynamic_variable

I then have the following code

----
function sendValue(var1, var2){
var selvalue = eval('selectform.' + var1 + '.value');
window.opener.document.taggingUI.var2.value += selvalue + ', ';
window.close();
----

var1 is no problem. var2 isn't working. I've tried a whole bunch of
things, nothing works!! I need to insert var2 in that spot, and it's
urgent.

If you have an idea, please let me know....

Thanks!
djsphynx insert the at symbol hot mail dot com
 
L

Lasse Reichstein Nielsen

(e-mail address removed) (Rob) writes:

PLEASE use a descriptive subject. While cute, this isn't it.
I have a form - when you click the submit button, it appends a
variable to the URL (e.g. xyz.cgi?inputID=some_dynamic_variable)

Does it append that to the "action" attribute of the form element, or
is it part of the normal form submission?
It also opens a new page.

How? When?
Now, that some_dynamic_variable is actually the name of a form
element on the parent window.

Parent window of the new window (i.e., the current) or parent window
of the current window?
On the new page, I have this javascript:

Good, so that works.
I then have the following code

Never use "eval" to acces properties of object. There are safer and
more efficient ways to do that (as for almost any use of "eval" - just
don't use it!).

var selvalue = document.forms['selectform'].elements[var1].value;

window.opener.document.taggingUI.var2.value += selvalue + ', ';

window.opener.document.forms['taggingUI'].elements[var2].value +=
selvalue+', ';
window.close();

So the new window is just a way of doing a fetch without killing the
page.

Unless you use Mozilla.
var2 isn't working.

See said:
I've tried a whole bunch of things, nothing works!!

I was about to suggest you read a book about Javascript, but just
picking any book is likely to make matters worse :)


Read the FAQ! All og it! it's all good advice.
(Now we know that you know, and so we will expect you to not ask
questions answered by the FAQ :p )

And to learn about JavaScript, try this:
I need to insert var2 in that spot, and it's urgent.

Ah, will you pay for it? :)
(Damn! Too late now!)

/L
 
I

Ivo

I have a form - when you click the submit button, it appends a
variable to the URL (e.g. xyz.cgi?inputID=some_dynamic_variable)

Is this done by the form itself with the common get method, or do you do
this with javascript?
It also opens a new page.

You mean a popup? How?
Now, that some_dynamic_variable is actually
the name of a form element on the parent window.

On the new page, I have this javascript:

Needless eval, where does it come from? What is selectform? I 'm asking not
only because I don't know but also many browsers won't know, hence occurs
occur. My human instinct tells me it 's a reference to a form. You need to
tell the browser that in a more formal way. I 'd need to see more code (an
url?) to say exactly how. It 's probably along the lines of:

var selvalue = document.forms[ 'selectform' ].elements[ var1 ].value;

window.opener.document.taggingUI.var2.value += selvalue + ', ';

Ay ay. var2 is clearly taken just as literally as taggingUI in this syntax,
but what you want its value. Take a good look at the quotes around
selectform and the absence of quotes around var1 above. That 's how it 's
done.
What is taggingUI? The id of something in the opener document? Then use
getElementById, like so:

window.opener.document.getElementById( 'taggingUI' )

Or it 's the form you mentioned, right? Then

window.opener.document.forms[ 'taggingUI' ]

is even better supported among browsers.
These are just some urgent pointers, but you need to take some time to read
up on some basics and the wider picture (beyond IE).
HTH
Ivo
window.close();
----

var1 is no problem. var2 isn't working.
I've tried a whole bunch of
things, nothing works!! I need to insert var2 in that spot, and it's
urgent.

What isn't?
 
L

Lee

Rob said:
var1 is no problem. var2 isn't working. I've tried a whole bunch of
things, nothing works!! I need to insert var2 in that spot, and it's
urgent.

If you have an idea, please let me know....

Now that you've got a couple of answers, I'd like to hear how
you managed to get yourself into an "urgent" coding situation
without knowing something this basic? Is this for a class?
How long have you been putting this off?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top