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

window.open location.href frame

Hello
I have a page of 2 frame:
menu (menu.php)
corpo (corpo.php)

In menu.php i have:
<script>
function selAut(){
aut=autore.selectedIndex;
aut=autore.options[aut].value;
parent.corpo.location.href('http://www.laltrarete.it/mipiace/corpo.php?autore=aut');
return true
}
</script>
seleziona gli articoli per autore:
<select name="autore" onsubmit="selAut()" target="corpo">

But the browser try to open 'MENU.php?autore=aut'
instead of
CORPO.php?.....
as i'd like.

I tried even with
window.open('http://www.laltrarete.it/mipiace/corpo.php?autore=aut',
'corpo');
but i got the same problem
Any suggestion?
thanks in advance
and sorry for my bad english
Marcello
Jul 20 '05 #1
4 15536
Marcello wrote:
I have a page of 2 frame:
menu (menu.php)
corpo (corpo.php)

In menu.php i have:
<script>
The `type' attribute is missing for valid HTML 4.
function selAut(){
aut=autore.selectedIndex;
That variable is declared and defined global
since the `var' keyword is missing. Bad style.
aut=autore.options[aut].value;
The `autore' reference is defined nowhere. Only in some UAs like IE
`identifier' automagically creates a reference to an element named
`identifier', by document.all("identifier"). Pass a reference to the
object explicitely instead. Since the method is invoked when the event
fires for the object you access, the `this' operator and keyword serves
the purpose.
parent.corpo.location.href('http://www.laltrarete.it/mipiace/corpo.php?autore=aut');
location.href is a non-function property, i.e. no method.
Downwards compatible is the assignment to `location' instead
of to `location.href'.
return true
}
</script>
seleziona gli articoli per autore:
<select name="autore" onsubmit="selAut()" target="corpo">
The `select' element has no (working) `onsubmit' event
handler, the `form' element has. You were looking for

<script type="text/javascript>
function dummy(x)
{
return x;
}

function selAut(o)
{
if (!o
|| !o.options
|| !o.selectedIndex
|| o.selectedIndex < 0)
return false;

var aut = o.options[o.selectedIndex].value;

/*
* Define the method to convert the value
* of the form element for a valid URI
* Preference order is: encodeURIComponent,
* escape, dummy.
*/
var f =
(typeof encodeURIComponent != "undefined"
? encodeURIComponent
: (typeof escape != "undefined"
? escape
: dummy));

parent.corpo.location =
'http://www.laltrarete.it/mipiace/corpo.php?autore='
+ f(aut);

return true;
}
</script>

<select name="autore" onchange="selAut(this)">

and did not consider users with a keyboard whose navigation you make
worse with this, for without special keys they can either select the
first item only or have JavaScript disabled and miss the functionality
you provided. Thus discard the `onchange' event handler and use
`onsubmit' for the `form' element instead, also providing a server-side
alternative with the `action' attribute for users without client-side
JavaScript support where the event cannot be handled.

BTW: Do not use tab characters in your code, their display depends on
the client. Spaces (two recommended) will best serve the purpose of
indentation.
But the browser try to open 'MENU.php?autore=aut'
instead of
CORPO.php?.....
I hope you know that filenames on servers are case-sensitive in most
cases.
I tried even with
window.open('http://www.laltrarete.it/mipiace/corpo.php?autore=aut',
'corpo');
This statement also misses the dynamic `aut' part. Unlike other script
languages like PHP, variable identifiers are not automatically replaced
by their value within string literals in JavaScript.
but i got the same problem


BAD. Broken as designed.
PointedEars
Jul 20 '05 #2
Thank you very much, Thomas. It was a long and egsaustive
help. Nevertheless, it seems it still doesn't work.
At the moment my menu.php is

<?php
[omissis]
foreach ($line as $col_value) {
print "<td><a href=\"corpo.php?tema=$col_value\"
target=\"corpo\">$col_value</a></td>\n";
}
print "\t</tr>\n";
[omissis]
?>
<div>
<script type="text/javascript">
function dummy(x){
return x;
}
function selAut(o){
if (!o
|| !o.options
|| !o.selectedIndex
|| o.selectedIndex < 0)
return false;
var aut = o.options[o.selectedIndex].value;
var f =
(typeof encodeURIComponent != "undefined"
? encodeURIComponent
: (typeof escape != "undefined"
? escape
: dummy));
parent.corpo.location =
'http://www.laltrarete.it/mipiace/corpo.php?autore='
+ f(aut);
return true;
}
</script>

<form action="" onsubmit="selAut(this)">
seleziona gli articoli per autore:
<select name="autore" >
<?php
$queryAutore=mysql_query("select username
from autori");
while
($line=mysql_fetch_row($queryAutore){
foreach ($line as $autore) {
print ("<option name=\"autore\"
value=\"$autore\">$autore</option>"); }
}
?>
</select>
<input type=submit value="seleziona" >
</form>
[omissis]

but the problem is the same : the query string is passed but the url
passed is bad menu.php insteead of corpo.php
(upper case in the previous message was mine, just for emphasis).
also providing a server-side
alternative with the `action' attribute

yes but how can i do that?
The first line of code above is only based on php,
but here i need some more compact (as a select) , in order to make the
page shorter.
Thank you again and sorry for my bad english
Marcello

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Marcello Console wrote:
Thank you very much, Thomas.
You are welcome.
It was a long and egsaustive help. Nevertheless, it seems it
still doesn't work.
The main problem is that you do not call the method correctly
because you have not understood what it is doing exactly. You
should read more on JavaScript and DOM(s) before you continue
programming.
At the moment my menu.php is

<?php
Server-side script code is not useful for analyzing its client-side
consequences. Post what the client gets instead, *after* the PHP
Hypertext Preprocessor has replaced it.
[...]
<form action="" onsubmit="selAut(this)">
selAut(...), as it was rewritten by me, requires a reference to an
HTMLSelectElement object, not a HTMLFormElement object, as first
argument. So it must fail on

| if (!o
| || !o.options

here because an HTMLFormElement object referenced in the event handler of
the *form* element with `this' does not have a `options' property which
causes the `if' statement to evaluate to `true' and

| return false;

to execute with which the function is left.

Thus you need to use this.elements['autore'] instead of `this' *there*.
(upper case in the previous message was mine, just for emphasis).
Better to use *bold*, /italic/ and/or _underlined_ instead. Good
NetNews clients even format the text on display as described above.
also providing a server-side alternative with the `action' attribute


yes but how can i do that?


<form action="alternative.php" ... onsubmit="return selAut(this)" ...>

The event fires when the user clicks the submit button of the form and if
client-side JavaScript is supported it is then handled.[1] Because the
return value of the method is returned to the event handler, it is possible
to cancel the submit event, meaning that the UA will continue as if the
submit button was not pushed in the first place and thus ignoring the
`action' attribute. So either the method returns `false' always (currently
it only returns `false' on failure) or you leave it as is and use

<form
action="alternative.php"
...
onsubmit="selAut(this); return false;"
...


instead.

In either case, without JavaScript the UA will ignore the event handler and
use the `action' attribute to access a resource that is passed the input
data. You then can also use the `target' attribute to specify the name of
the window where the submit result should be displayed.

Maybe you already know the following:

There are two request methods available: GET and POST. GET, which is the
default, appends the data to the URI of the resource to be accessed like
`?name=value&name2=value2...'.[2] With POST, defined by `method="post"
for a `form' element, the URI remains unchanged but the form data is
included in the body of the HTTP request. Because of that, the latter is
suited for the transmission of extensive and/or sensitive information (the
submitted data is not stored in the history of the user as URL and the
limitations of length UAs and servers impose on URIs do not apply.) Having
PHP available, you can retrieve either information by the $_GET and $_POST
superglobal arrays, the $HTTP_GET_VARS and $HTTP_POST_VARS arrays or, with
the discouraged register_globals=on even with $name. (See the PHP manual for
details.)
HTH

PointedEars
___________
[1]
Define the default scripting language used for event handler code with

<meta http-equiv="Content-Script-Type" content="text/javascript">

within the `head' element.
[2]
Note that with JavaScript manipulating the `location' property, GET is used,
too. To let the UA perform a POST request initiated by JavaScript code, you
need either need to call the submit() method of a POST form after
manipulating its data or use advanced techniques like e.g. XMLHTTPRequest.
Google is your friend. [psf 6.1]
Jul 20 '05 #4
As i don't see my reply, i post it again.
Sorry if it is a deja-view for you.
Server-side script code is not useful for ... yes i know, but imput that rows in order to make more clear what i
whanted to do.
selAut(...), as it was rewritten by me, requires a >reference to an HTMLSelectElement object, ....
yes, it solved . What make me confused is that on the bwoser appeared
menu.php?autore=...., with exact(fit) query string, even if only for a
piece of second. So i investigate on bad url , instead of wrong passing
of parameter. Even now , i can see ...menu.php?autore...... Isn't it
strange?
also providing a server-side alternative with the `action' >>

attribute yes but how can i do that?
<form action="alternative.php" ... onsubmit="return >selAut(this)"
...>

I know i could put corpo.php?autore=$aut in the action, but what i don't
know is to pass 'target="corpo"' (corpo is the frame). If i'd known , i
wouldn't use javascript.
You should read more on JavaScript and DOM(s) before you >continue

programming.
Sure i must study js. But now i'm studing php, i just needed this for go
ahead. As for DOM, isn't it only for ms iexplorer?

Thank you again
Marcello

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5

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

Similar topics

10
by: Scott | last post by:
I'm new to ASP, but I've been programming in VB for several years, and I'm having a few issues with this ASP enhancement I'm working on. I've found ASP to be a lot different than what I'm use to...
1
by: ck388 | last post by:
I am trying to open a frameset in a new window......where the frame called "main" shows the file called customerGeneral.aspx. I can't get it to work though...i always get something like...
3
by: Farooq Karim | last post by:
Greetings; I am unable to solve this problem; I hope someone will come up to show his brilliance. From my web page I open another link in another browser window. That new window is composed...
3
by: sentinel | last post by:
Hi all, I'm trying to reload a frame from a pop-up, but really cannot figure this out. Within my index.htm file, I make a link to call a pop-up frame with a javascript function that calls the...
3
by: Phil | last post by:
how do I force a window, pened alone, to be displayed in its frame set? tried this: if (parent.location.href == self.location.href) { window.location.href = '../'; } the problem is that...
18
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to...
1
by: cglewis03 | last post by:
Hello, I am trying to build a search form with several different options to choose from. Currently it is set up to open within the same window if a single option is selected and open within a...
4
by: sid | last post by:
"about:blank" oepns new browser window I am writing a webpage that will run on other machines that I may or may not know about. My page is framed where frame1 controls the content of frame2. ...
6
by: mistral | last post by:
what is correct way open a PDF document in new window use hyperlink? I want show images thumbnails linked with PDF files, when click on thumbnail, PDF will be opened in new window. Some of PDF...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.