Passing data to a specific textbox

They have: 8 posts

Joined: Mar 2000

hi there...

i need your help...

i have a frame page...the upper frame has a drop-down and the lower frame has 5 text boxes.

i want to do following steps:

1. position the cursor on one of the text box located at the lower frame
2. it would activate a javascript that will get the variable name of the text box
3. select an item from the list
4. put the selected item into the textbox were the cursor was placed

As of that moment, only step 1 and 2 can be done...i need any ideas from you guys...

to demonstrate what i mean,pls check it out...the url is http://geocities.com/dudyboy_jfmjr/prototype/

thanx in advanced...

To Infinity and Beyond

Jack Michaelson's picture

He has: 1,733 posts

Joined: Dec 1999

Uhm... don't exactly undastand what u say...

You want a list item put in the textbox that was last focused?
Is that your problem? (if yes, I would have no idea how to fix it... Sad )

Shakespeare: onclick || !(onclick)

They have: 8 posts

Joined: Mar 2000

yes...thats what i mean...

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

I'm not entirely sure where you're going here, but here are some broadstrokes that may help.

In the DOM, each form has a value, and each field in a form has a value. Within frames, each frame has a value. Using JavaScript, you would target the different frames, forms and fields in order, like an onion.

document.frame.forms.field.value (you'll have to look up the actual names, I'm guess-remembering).

As such, in order to take something from one field and plunk it in another, you simply need to give it accurate directions.

By default, these values are [0] and up, like forms[0], however you can name each piece in the HTML like and and then you can control it with JavaScript by using...

document.smith.abigail.email.value

I hope that is of some help.

Smiling Suzanne

They have: 10 posts

Joined: Aug 2001

The way I see it, you would have to put a button for each textbox in the top frame with the dropdown menu. Then you can select an item from the list, and place it into one of the textboxes by pressing the corresponding button.

ie:
on the buttons in the top frame(next to the dropdown menu):

onClick="insertSelection('textbox1');return false;"

you could have this function call on each button, passing the name of the textboxes ie; textbox1, textbox2 textbox3 etc. as parameters.

then a function like:

function insertSelection(textbox)
{
var obj = eval('parent.mainframe.document.form.'+ textbox);
obj.value = this.document.dropdownmenu.value;
}

So if you hit button 1 after you select an item, you will insert the selected item into textbox1 in the other frame, just make sure everything is named correctly.

Good luck,

Go!

The more you learn the more you know how much there is you don't know.

They have: 10 posts

Joined: Aug 2001

Here is a better example using the onFocus event to set the target field instead of buttons - but alas, doesn't work in NN4. Works well in IE4+ and should work in NN6. You could add some server-side browser detection (or maybe client-side) to go either 'buttons' or 'onFocus' . You'll have to muck around with it.

Untitled Document

<script language="JavaScript">

</script>

Guy Hopkins
Erin Grubb
Justin Madden
Andy Reynolds

Untitled Document

<script language="JavaScript">

function setTextBox(tbox)
{
parent.topFrame.document.form1.textbox.value = tbox;
}
</script>

The more you learn the more you know how much there is you don't know.

They have: 8 posts

Joined: Mar 2000

yes...thanx for the input guys...

so the next thing i have to do now is validate if
the user had selected/clicked a textbox before selecting
an item in the list box...

thanx again and more power...

To Infinity and Beyond

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.