...

View Full Version : Popup Box for special text field GURU help needed



geomodules
05-08-2006, 10:44 AM
I need help from a GURU....

This opens the pop up box


<form method=post action='' name=state>
<table border=0 cellpadding=0 cellspacing=0 width=550> <tr>
<td ><font size=2 face='Verdana'>Your Name</font>
<input type=text name='p_name' size='8'>
<a href="javascript:void(0);" NAME="My Window Name" title=" My title here " onClick=window.open("child3.html","Ratting","width=550,height=170,left=150,top=200,toolbar=1,status=1,");>Click here to open the child window</a>
</td></tr> </table></form>


This is the child3.html code



<html>
<head>

<script langauge="javascript">
function post_value(){
opener.document.state.p_name.value = document.frm.me.value;
self.close();
}
</script>

<title>(Type a title for your page here)</title>
</head>


<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">


<form name="frm">


<select name="me">
<option value="AR">AR</option>
<option value="MN">MN</option>
<option value="CA">CA</option>
</select>




<table border=0 cellpadding=0 cellspacing=0 width=250>


<tr><td align="center"> Your name
<input type=button value='Submit' onclick="post_value();">
</td></tr>
</table></form>





Now this works great..... My problem is this... I am sending the info to text box. Which this should work. Except my text name has square brackets...



<input type=text name=c[optional_field_1] value="" size=2 maxlength=2 class=data_field_values>


Now the ME field I should just have to put in c[optional_field_1] and it should work. I can't rename this field so I have no choice but to find a way for java script to work with it some how....

My form name is. <form name=registration_form
text field to send to. c[optional_field_1]

I plan to have 6 popups using a different field.
c[optional_field_1]
c[optional_field_2]
c[optional_field_3]
c[optional_field_4]
c[optional_field_5]
c[optional_field_6]

For some reason Java script does not like those SQUARE brackets. I am new. So any help would be great.

thx...:cool:

Kor
05-08-2006, 10:52 AM
Welcome to the Forum.

javascript likes square brackets, but it likes also you to learn to use it:

you field must be send to:

opener.document.forms['registration_form'].elements['c[optional_field_1]']
or even
opener.document['registration_form']['c[optional_field_1]']

geomodules
05-08-2006, 11:05 AM
Welcome to the Forum.

javascript likes square brackets, but it likes also you to learn to use it:

you field must be send to:

opener.document.forms['registration_form'].elements['c[optional_field_1]']
or even
opener.document['registration_form']['c[optional_field_1]']


I keep getting erros when I try this :(

is NULL or not and Object....

Kor
05-08-2006, 11:12 AM
Really?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
onload=function(){
alert(document.forms['registration_form'].elements['c[optional_field_1]'].value)
}
</script>
</head>
<body>
<form name="registration_form">
<input name="c[optional_field_1]" type="text" value="bla">
</form>
</body>
</html>

geomodules
05-08-2006, 11:30 AM
I can't get it to work...LOL.... Can you use mine pretty please...

********html 1********run this first


<form method=post action='' name=state>



<table border=0 cellpadding=0 cellspacing=0 width=550> <tr>
<td ><font size=2 face='Verdana'>Your Name</font>

<input type=text name='registration_form' size='8'>


<a href="javascript:void(0);" NAME="My Window Name" title=" My title here " onClick=window.open("child3.html","Ratting","width=550,height=170,left=150,top=200,toolbar=1,status=1,");>Click here to open the child window</a>



</td></tr> </table></form>




*****HTML 3 name it to child3.html ****



<html>
<head>

<script langauge="javascript">
function post_value(){
opener.document.state.registration_form.value = document.frm.me.value;
self.close();
}
</script>

<title>(Type a title for your page here)</title>
</head>


<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">


<form name="frm">


<select name="me">
<option value="AR">AR</option>
<option value="MN">MN</option>
<option value="CA">CA</option>
</select>




<table border=0 cellpadding=0 cellspacing=0 width=250>


<tr><td align="center"> Your name
<input type=button value='Submit' onclick="post_value();">
</td></tr>
</table></form>





Has something to do with the state field....


opener.document.state.registration_form.value = document.frm.me.value;

Kor
05-08-2006, 12:01 PM
Make up your mind. You said so:


My form name is. <form name=registration_form
text field to send to. c[optional_field_1]

if so, the reference is
opener.document.forms['registration_form'].elements['c[optional_field_1]']

If not, use the correct names of the form and of the text field

opener.document.forms['yourformname'].elements['yourtextfieldname']

geomodules
05-08-2006, 12:08 PM
Make up your mind. You said so:

if so, the reference is
opener.document.forms['registration_form'].elements['c[optional_field_1]']

If not, use the correct names of the form and of the text field

opener.document.forms['yourformname'].elements['yourtextfieldname']

I am sorry:confused: php is my game. I am so lost... For 3 days I have been trying to make this work. All I want it to do is open a pop window then I select from the drop down box and put it in the text field. The square brackets came back with the errors.... This whole line is needed in order for the pop up to work



opener.document.state.registration_form.value = document.frm.me.value;


the state field is taken from the 1st page.
<form method=post action='' name=state>

I have tried every possible configuration I can think using this but mine has no elelement so I though lets play. I keep moving them around. You seem to understand this very well. Please forgive me if I don't understand. No matter what I do I can't get it to work. Any help can give would be great. :thumbsup:

Kor
05-08-2006, 12:14 PM
you need also events:

.....
onload=post_value;
...
<select name="me" onchange="post_value()">

But, for God's sake, tell me which are the names YOU are using in the opener. Meake it clear once for ever.

geomodules
05-08-2006, 12:25 PM
Ok I will explain it the best I can.....


This is my first html page.... you will see the name state


<form method=post action='' name=state>
<table border=0 cellpadding=0 cellspacing=0 width=550> <tr>
<td ><font size=2 face='Verdana'>Your Name</font>
<input type=text name='registration_form' size='8'>
<a href="javascript:void(0);" NAME="My Window Name" title=" My title here " onClick=window.open("child3.html","Ratting","width=550,height=170,left=150,top=200,toolbar=1,status=1,");>Click here to open the child window</a>
</td></tr> </table></form>

which is calling the child3.html page.....



<html>
<head>
<script langauge="javascript">
function post_value(){
opener.document.state.registration_form.value = document.frm.me.value;

self.close();
}
</script>
<title>(Type a title for your page here)</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<form name="frm">
<table border=0 cellpadding=0 cellspacing=0 width=250>
<tr><td align="center"> Select State
<select name="me">
<option value="AR">AR</option>
<option value="MN">MN</option>
<option value="CA">CA</option>
</select>
<input type=button value='Submit' onclick="post_value();">
</td></tr>
</table></form>



The above works GREAT... just not with c[optional_field_1] because of square brackets.

So the java code is as follows.
function post_value(){
opener.document.state.registration_form.value = document.frm.me.value;
self.close();
}

state being taken from the 1st html page which starts the popup
registration_form is the name of the form in the 2nd html
I have me in there because some how I need to change this to c[optional_field_1]


opener.document.state.registration_form.value = document.frm.me.value;

I hope I explained it well.....

Kor
05-08-2006, 12:30 PM
once again, WRITE THE NAMES YOU WANT TO USE NOW. Leave me about what it had worked in the past...
What is so hard to understand, after all? Put your names u want to use in the place of the red italic strings bellow

document.forms['putherethenameoftheform'].elements['putherethenameofyourelement']

geomodules
05-08-2006, 12:37 PM
once again, WRITE THE NAMES YOU WANT TO USE NOW. Leave me about what it had worked in the past...
What is so hard to understand, after all? Put your names u want to use in the place of the red italic strings bellow

document.forms['putherethenameoftheform'].elements['putherethenameofyourelement']


Mine
opener.document.state.registration_form.value = document.frm.me.value;

Yours
document.forms['registration_form'].elements['c[optional_field_1]']


maybe??
opener.document.state.['registration_form'].value = document.frm.['c[optional_field_1]'.value;

I get expected identifier..... *sigh*

Kor
05-08-2006, 12:45 PM
Sir you are not attentive at all regarding the syntax. Forms' elements are to be refere in many ways, but don't mixt them

document.formname.elementname
or
document.forms['formname'].elements['elementname']
or
document.formname.elements['elementname']
or
document.forms['formname'].elementname
or
document.forms['formname']['elementname']
or
document['formname']['elementname']

Take care about when and how to use dots and quotes.

geomodules
05-08-2006, 12:46 PM
if I do this with it....

<script langauge="javascript">
function post_value(){

opener.document.forms['registration_form'].elements['c[optional_field_1]'].value;


self.close();
}


I comes back with
opener.document.forms.registration_form.elements is NULL or not and object...

I'm trying....:(

Kor
05-08-2006, 12:50 PM
Man. let's take from the begining; In the opener you have a form and a textfield

form name =?
text field name=?

In the popup you have a form and a text box.

form name=?
text box name =?

Now, which must be the event in the popup wich will tranfere a value from the textbox in popup to the textfield in the opener?

geomodules
05-08-2006, 01:03 PM
Man. let's take from the begining; In the opener you have a form and a textfield

<form method=post action='' name=state>
form name = state
<input type=text name="registration_form" size='8'>
text field name =registration_form

In the popup you have a form and a text box.

<form name="frm">
form name = frm
<select name="c[optional_field_1]">
text box name = c[optional_field_1]

A drop down box will load with states... they select state and click submit button.

take from drop down and sent to c[optional_field_1]

Now, which must be the event in the popup wich will tranfere a value from the textbox in popup to the textfield in the opener?

Kor
05-08-2006, 01:25 PM
opener.document.forms['state'].elements['registration_form'].value=document.forms['frm'].elements['c[optional_field_1]'].value

geomodules
05-08-2006, 01:35 PM
opener.document.forms['state'].elements['registration_form'].value=document.forms['frm'].elements['c[optional_field_1]'].value

YES!!!! Your AWESOME!!!....:thumbsup: :thumbsup: :thumbsup: :thumbsup:

Thank you so much!!!! :thumbsup: :thumbsup: :thumbsup: :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum