Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27599 > unrolled thread
| Started by | bit-naughty@hotmail.com |
|---|---|
| First post | 2015-05-11 11:00 -0700 |
| Last post | 2015-05-13 10:50 +0200 |
| Articles | 10 — 4 participants |
Back to article view | Back to comp.lang.javascript
Javascript needed to work in tandem with a backend bit-naughty@hotmail.com - 2015-05-11 11:00 -0700
Re: Javascript needed to work in tandem with a backend "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-11 20:36 +0200
Re: Javascript needed to work in tandem with a backend bit-naughty@hotmail.com - 2015-05-13 10:35 -0700
Re: Javascript needed to work in tandem with a backend "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-13 22:54 +0200
Re: Javascript needed to work in tandem with a backend danca <cyberdanny@tiscalinet.it> - 2015-05-14 12:05 +0200
Re: Javascript needed to work in tandem with a backend bit-naughty@hotmail.com - 2015-05-18 10:32 -0700
Re: Javascript needed to work in tandem with a backend Tim Streater <timstreater@greenbee.net> - 2015-05-18 18:50 +0100
Re: Javascript needed to work in tandem with a backend danca <cyberdanny@tiscalinet.it> - 2015-05-19 19:00 +0200
Re: Javascript needed to work in tandem with a backend bit-naughty@hotmail.com - 2015-05-21 06:30 -0700
Re: Javascript needed to work in tandem with a backend danca <cyberdanny@tiscalinet.it> - 2015-05-13 10:50 +0200
| From | bit-naughty@hotmail.com |
|---|---|
| Date | 2015-05-11 11:00 -0700 |
| Subject | Javascript needed to work in tandem with a backend |
| Message-ID | <cfe30f66-74a1-4a03-890a-5914e9e2aff7@googlegroups.com> |
Hi, I want that a menu should popup on a mouseclick on a couple of <div>s onscreen, with for example, a URL as one of the clickable options, ie. "Click this to go to yahoo.com". Thing is, the URL will need to be with args to the backend PHP script, ie. 'yahoo.com/search="gloop" '.However the page itself will by a dynamically generated one, ie. the backend script has to fill in the "gloop", according to whatever behaviour I want. How to do this, please? I'm getting a little confused as to the quoting, for starters. Can you guys help? :) Thanks so much.
[toc] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2015-05-11 20:36 +0200 |
| Message-ID | <XnsA497D1A397B80eejj99@194.109.133.246> |
| In reply to | #27599 |
bit-naughty@hotmail.com wrote on 11 mei 2015 in comp.lang.javascript: > I want that a menu should popup on a mouseclick on a couple of <div>s > onscreen, with for example, a URL as one of the clickable options, ie. > "Click this to go to yahoo.com". Thing is, the URL will need to be with > args to the backend PHP script, ie. 'yahoo.com/search="gloop" '.However > the page itself will by a dynamically generated one, ie. the backend > script has to fill in the "gloop", according to whatever behaviour I > want. > > How to do this, please? I'm getting a little confused as to the quoting, > for starters. Can you guys help? :) Show sho what you have done sofar. Show us what methods you have found on the web. Otherwise it would not be helping, but doing your work. > for starters. Meaning you will give us more work laater? -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | bit-naughty@hotmail.com |
|---|---|
| Date | 2015-05-13 10:35 -0700 |
| Message-ID | <ec1d667a-8b16-4529-a1d7-22afc37e8300@googlegroups.com> |
| In reply to | #27601 |
OK, danca, Sorry, but my brain is just not working very well right now, so I'll read and understand what you said later, and get back to you, is that OK? :)
In the meantime, let me just tell you guys what's been going on in my mind:
For the Menu that I'm talking about, I guess the entire thing has to be put in a <DIV> and </DIV> - but how do I show that <DIV> upon a mouseclick? It'll be just like a right click menu, but only stylised with proper colours and fonts and stuff. The z-index has to be, umm.. greater than the actual page's, right? But how do I make it appear where the mouse is?
The scenario is: Suppose there's a pink box and a blue box on the page, clicking the pink one should give you the menu with an option to search Yahoo for pink boxes, and clicking the blue one, for blue boxes.
So the <div>s for each box need to have both a class AND an id, right? A class for the onclick menu to show up, i.e. Javascript will have to show the menu when it's clicked, is it something to do with "visibility"? And an id so that the parameters to Yahoo search can be put in (yahoo.com/?search=bluebox). But how do I do this?
There is one line of .js for EACH box ,i.e. x.onclick= , but is there a way to *change the args* to the .js for each box? Is this what you were talking about, danca?
Oh, and *all this stuff* will be coming down via AJAX, ie. both pink and blue boxes will be shown AFTER viewer clicks a particular button ("show boxes"), so how do you put these dynamically generated .js's into the <head> of the page? The only thing I'm familiar with is "innerHTML", is that the right thing to use here?
I don't want anyone to feed me the answer, I'd just like to discuss the *theory* behind all of this before I attempt writing something. This is my FIRST major site with CSS and JS, guys, go easy on me! :)
Thanks a lot for your help, danca! :)
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2015-05-13 22:54 +0200 |
| Message-ID | <XnsA499E8FD7DB97eejj99@194.109.133.246> |
| In reply to | #27614 |
bit-naughty@hotmail.com wrote on 13 mei 2015 in comp.lang.javascript: > .. so I'll read and understand what you said ... What and who are you responding to? This is not email but usenet, hold to netiquette please! -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | danca <cyberdanny@tiscalinet.it> |
|---|---|
| Date | 2015-05-14 12:05 +0200 |
| Message-ID | <mj1rv1$j9v$1@dont-email.me> |
| In reply to | #27614 |
Il 13/05/2015 19:35, bit-naughty@hotmail.com ha scritto:
> OK, danca, Sorry, but my brain is just not working very well right
> now, so I'll read and understand what you said later, and get back to
> you, is that OK? :)
>
> In the meantime, let me just tell you guys what's been going on in my
> mind:
>
> For the Menu that I'm talking about, I guess the entire thing has to
> be put in a <DIV> and </DIV> - but how do I show that <DIV> upon a
> mouseclick? It'll be just like a right click menu, but only stylised
> with proper colours and fonts and stuff. The z-index has to be, umm..
> greater than the actual page's, right? But how do I make it appear
> where the mouse is?
>
A <div> can be made visible or hidden setting the style.visibility, of
course you must first get a reference to the object <div> in the DOM. So
you can assign an id to your div and then retrieve it with the command
getElementById, f.e:
document.getElementById("mydiv").style.visibility="hidden"
> The scenario is: Suppose there's a pink box and a blue box on the
> page, clicking the pink one should give you the menu with an option
> to search Yahoo for pink boxes, and clicking the blue one, for blue
> boxes.
>
> So the <div>s for each box need to have both a class AND an id,
> right?
It's not that the div MUST have something, it's up to you to decide how
to manage it.
The class has little to do with javascript, it is referred to the CSS,
while the id is a convenient way to identify a single element and is
widely used with (but not only) javascript.
F.e you can retrieve elements in the DOM with the commands:
getElementsByTagName() or, document.<elementsCollection>[ordinalnumber],
(supposing to have a form via document.forms[0].item(0) retrieves the
first element in the form).
...
> one line of .js for EACH box ,i.e. x.onclick= , but is there a way to
> *change the args* to the .js for each box? Is this what you were
> talking about, danca?
Yes, you can access any element in the DOM via js, and change the
properties/attributes that allows to be changed (some are read-only)
>
> Oh, and *all this stuff* will be coming down via AJAX, ie. both pink
> and blue boxes will be shown AFTER viewer clicks a particular button
> ("show boxes"), so how do you put these dynamically generated .js's
> into the <head> of the page? The only thing I'm familiar with is
> "innerHTML", is that the right thing to use here?
The scripts are usually placed in the head but this is not mandatory: in
fact you can put a script everywhere in a page.
To put a script in the head dinamically you must have some experience
with js, f.e. you must retrieve the element <head>, then use appendChild
etc., not a thing for beginners, probably:
here a simple example to insert a script at the end of the current document:
var newscript=document.createElement("script")
newscript.type="text/javascript"
newscript.id="script0"
newscript.text="alert('Hi')"
document.appendChild(newscript)
>
>
> I don't want anyone to feed me the answer, I'd just like to discuss
> the *theory* behind all of this before I attempt writing something.
> This is my FIRST major site with CSS and JS, guys, go easy on me! :)
>
> Thanks a lot for your help, danca! :)
>
Anyway this newsgroup is one of the best places to find answers to
complex issues, but probably is not thest place for a beginner: I am far
from an "expert", and probably my answers can be, strictly speaking,
inaccurate/imprecise. If you will become a regular lurker here you will
learn A LOT but the experience of asking for help can be a little
frustrating, as you probably already suspect (the answer from
evertjan...). Read te FAQ's and try to be as precise as possible or
you'll be ignored or, worse, you'll get elusive answers regarding the
way you pose the question, your signature, the way you are quoting,"this
is not an helpdesk", "do your homework" and so on. :-)
My 2 cents
Dan
[toc] | [prev] | [next] | [standalone]
| From | bit-naughty@hotmail.com |
|---|---|
| Date | 2015-05-18 10:32 -0700 |
| Message-ID | <d579b356-f9b3-4a0b-acd2-b5d94b29766f@googlegroups.com> |
| In reply to | #27621 |
Heh, you may not be an expert, but you sure were of great help to ME! :) Thanks! :) I'm actually quite used to this type of behaviour, encountered it on other places I go to, but I've learned not to let people like evertjan get to me. Sour bastard. I think you're going to have to hold my hand a bit more about the x.onclick stuff though. Suppose my menu (the one that's going to show up when the box is clicked), is like this: <div> <a href="">Click here to search Yahoo for blue boxes</a> </div> The href= will be filled in by the *server side PHP*, am I right? Oh , and what's the opposite of "visibility"? Like, how do I *show* something? By the way, I've read The Definitive Guide, so it's not that I'm not knowledgable! :) But that's just a textbook type of book, actually needing to build a *site* with that knowledge requires me to hang out here... What's "danca" by the way, your name is Dan, and you're from Canada? :)
[toc] | [prev] | [next] | [standalone]
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Date | 2015-05-18 18:50 +0100 |
| Message-ID | <180520151850365420%timstreater@greenbee.net> |
| In reply to | #27736 |
In article <d579b356-f9b3-4a0b-acd2-b5d94b29766f@googlegroups.com>, <bit-naughty@hotmail.com> wrote: >Heh, you may not be an expert, but you sure were of great help to ME! :) >Thanks! :) > >I'm actually quite used to this type of behaviour, encountered it on other >places I go to, but I've learned not to let people like evertjan get to me. >Sour bastard. > >I think you're going to have to hold my hand a bit more about the x.onclick >stuff though. >Suppose my menu (the one that's going to show up when the box is clicked), is >like this: > ><div> ><a href="">Click here to search Yahoo for blue boxes</a> ></div> Well now, that's not a menu, is it? It's just a clickable link. D'ye want a drop-down menu here? If so you need a <select> probably inside a <form>. I don't know whether you want a static menu (by which I mean it doesn't change during the life of the application) or whether you need to load it up with stuff read from a database. >The href= will be filled in by the *server side PHP*, am I right? If you code it up to do that. Or you can use clientside javascript to assign something to the href property. >Oh, and what's the opposite of "visibility"? Like, how do I *show* something? Why don't you google for such as "html visibility" or "css visibility"? Mostly stuff is visible by default and you have to explicitly hide it. -- "Please stop telling us what you feel. Please stop telling us what your intuition is. Your intuitive feelings are of no interest whatsoever, and nor are mine. I don't give a bugger what you feel, or what I feel. I want to know what the evidence shows." -- Richard Dawkins
[toc] | [prev] | [next] | [standalone]
| From | danca <cyberdanny@tiscalinet.it> |
|---|---|
| Date | 2015-05-19 19:00 +0200 |
| Message-ID | <mjfq61$4l6$1@dont-email.me> |
| In reply to | #27736 |
Il 18/05/2015 19:32, bit-naughty@hotmail.com ha scritto: > > I think you're going to have to hold my hand a bit more about the > x.onclick stuff though. Suppose my menu (the one that's going to show > up when the box is clicked), is like this: > > <div> <a href="">Click here to search Yahoo for blue boxes</a> > </div> > > The href= will be filled in by the *server side PHP*, am I right? > Well, I don't use PHP (server side I use my own CGI's written in xBase) but you need to invoke PHP at least... and there is no <PHP> tag in the code we are talking about, so... I don't know how do you think to do that. > > Oh , and what's the opposite of "visibility"? Like, how do I *show* > something? style.visibility="visible" as opposite to "style.visibility="hidden" > By the way, I've read The Definitive Guide, so it's not that I'm not > knowledgable! :) But that's just a textbook type of book, actually > needing to build a *site* with that knowledge requires me to hang out > here... > > What's "danca" by the way, your name is Dan, and you're from Canada? > :) Oh no, I'm from Italy, DanCa comes from Daniele Campagna... :-) Dan
[toc] | [prev] | [next] | [standalone]
| From | bit-naughty@hotmail.com |
|---|---|
| Date | 2015-05-21 06:30 -0700 |
| Message-ID | <63abb0b4-7c10-4a2f-9a5a-956fa780360f@googlegroups.com> |
| In reply to | #27759 |
On Tuesday, May 19, 2015 at 10:30:59 PM UTC+5:30, danca wrote: > Il 18/05/2015 19:32, bit-naughty ha scritto: > Well, I don't use PHP (server side I use my own CGI's written in xBase) > but you need to invoke PHP at least... and there is no <PHP> tag in the > code we are talking about, so... I don't know how do you think to do that. Oh no no, just meant that IS how it's done....? I will be writing the PHP later.... > Oh no, I'm from Italy, DanCa comes from Daniele Campagna... :-) > > Dan Cool! :) Do you like pizzas? :)
[toc] | [prev] | [next] | [standalone]
| From | danca <cyberdanny@tiscalinet.it> |
|---|---|
| Date | 2015-05-13 10:50 +0200 |
| Message-ID | <miv369$7au$1@dont-email.me> |
| In reply to | #27599 |
Il 11/05/2015 20:00, bit-naughty@hotmail.com ha scritto:
> Hi, I want that a menu should popup on a mouseclick on a couple of
> <div>s onscreen, with for example, a URL as one of the clickable
> options, ie. "Click this to go to yahoo.com". Thing is, the URL will
> need to be with args to the backend PHP script, ie.
> 'yahoo.com/search="gloop" '.However the page itself will by a
> dynamically generated one, ie. the backend script has to fill in the
> "gloop", according to whatever behaviour I want.
>
> How to do this, please? I'm getting a little confused as to the
> quoting, for starters. Can you guys help? :)
>
>
> Thanks so much.
>
Something like this?
Menu:
<a href="yahoo.com/">Search</a>
<a href...> etc.
Input for the text to search:
Enter text to search:<input id="MyIn" type="text">
<button onclick="completeSearchURL()">Click me!</button>
...
A simple script that adds the text entered to the menu href's
<script>
function completeSearchURL(){
var text2add=document.getElementById("MyIn").value;
var aMenu=document.getElementsByTagname("a");
for(var j=0;j<aMenu.length;++j){aMenu[j].href=aMenu[j].href+text2add}
}
HTH
Dan
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web