On Apr 30, 11:20 am, "Richard" <s...@justmedal s.comwrote:
Greetings.
I am total newbie to Javascript so what is written below is
probably a bunch of cobblers!! Any assistance in correcting
my code much appreciated.
I wish the popped up child to pass value from the select box
to a text box on the parent form.
Here are my pages (in part)
parent.html
<html><head><ti tle>Parent Page</title></head><body>
<FORM NAME="ListingFo rm">
Use Lookup <input type="text" size="60" name="showValue ">
<br>
<A HREF= "#" onClick="window .open('child1.h tml','Sample',
'toolbar=no,wid th=520,height=5 50,left=10,top= 10, status=no,scrol lbars=no,
resize=no');ret urn false"><font style=FONT-SIZE:8pt>TABLE LOOKUP</A>
</form></body></html>
child1.html
<html><head><ti tle>Child1</title>
<SCRIPT LANGUAGE="Javas cript" TYPE="text/Javascript">
function setvalue(Listin gForm,showValue )
{
var mainpage = window.opener;
parent.ListingF orm.showValue
}
</script></head>
<form>
<select name="Options"
onchange="docum ent.ListingForm .showValue.valu e=this.value">
<option value="">Please select an option</option>
<option value="first option">first option</option>
<option value="second option">second option</option>
<option value="third option">third option</option>
<option value="forth option">fourth option</option>
</select></form>
I have no problem populating the text field on the form if the lookup
table is also part of the same form - but that is not what I need to
achieve.
you should have carried on with the thread " Help please with form
field population from a 2nd page" really.
child1.html ------------------8<------------
<html>
<head>
<title>Child1 </title>
<script type="text/javascript">
function setvalue(select value)
{
var t = window.opener;
var sender = ( !t || t.closed ) ? alert('parent window was closed') :
t;
sender.document .ListingForm.sh owValue.value = selectvalue;
}
</script>
</head>
<body>
<form>
<select name="Options" onchange="setva lue(this.value) ">
<option value="">Please select an option</option>
<option value="first option">first option</option>
<option value="second option">second option</option>
<option value="third option">third option</option>
<option value="forth option">fourth option</option>
</select>
</form>
</body>
</html>
-------------------8<-----------
parent.html-----------------8<----------------
<html>
<head>
<title>Parent Page</title>
</head>
<body>
<form name="ListingFo rm">
Use Lookup
<input type="text" size="60" name="showValue ">
<br>
<A HREF= "#" onClick="var
win=window.open ('child1.html', 'Sample','toolb ar=no,width=520 ,height=550,lef t=10,top=10,
status=no,scrol lbars=no,resize =no');return false">TABLE LOOKUP</A>
</form>
</body>
</html>
try to understnad whats been posted, dont just copy and paste and
leave it at that, what if the pop up appears below the current window?
what if the parent closes and the pop up is left orphaned, how about
focusing back to the parent and closing the pop up when a select is
made, or how about focusing back to the parent but setting the url of
the child to the next select, so it loads in the background and can
just be focused. by using a non standrd way of filling out a simple
form, you are creating usability hurdles for you and your users -
which you can only solve using a scripting language which itself
reduces the audience and legality - unless you provided a straight
forward alternative for those who need it.
by the way, your code is pretty sloppy, copy and paste job mixed with
bad markup, whats the action of the form, what method, why use a popup
to do this when it isnt accessible, the time for 20 selects each with
100 options is negligible compared to an image, so compress your
images properly, and dont overload the form page, and just use a
standard appraoch - like everyone else. Dont try to be the one with
the cunning new method - even its a great method your clients will
still be confused that you do it differently, if they can even access
the pop up - which are mostly blocked these days and are bad practise
anyway.