javascript > variable reset help!

C

CADD

I've used http://www.bloglines.com to add RSS feeds to my sites there
and setup javascript in my website to search bloglines for the input
term.

The code below works perfect, but I have 1 minor issue, hopefully
someone more family with javascript can help me out with.

1) the variables do not reset, so any future searches return the same
previous returned link, unless i clear settings/cookies.

{CODE}

<script language="JavaScript">
var name = "<person/>";
<![CDATA[
function Popup(){
var rssURL = "http://www.bloglines.com/search?q=";
var winWidth=800;
var winHeight=600;
var winScrollbars="yes";
var winToolbar="yes";
var winSizeable="yes";
var winLocation="yes";
var winDirectories="yes";
var winStatus="yes";
var winMenubar="yes";
var winCopyHistory="yes";
newWin=window.open(rssURL+name,"",
"copyhistory="+winCopyHistory+
",menubar="+winMenubar+
",status="+winStatus+
",directories="+winDirectories+
",location="+winLocation+
",resizable="+winSizeable+
",toolbar="+winToolbar+
",scrollbars="+winScrollbars+
",height="+winHeight+
",width="+winWidth);
}
]]>
</script>
<a href="javascript:popup()"><person/></a>
{END CODE}

Any help would be greatly appreciated.

CADD
 
N

Nikita the Spider

"CADD said:
I've used http://www.bloglines.com to add RSS feeds to my sites there
and setup javascript in my website to search bloglines for the input
term.

The code below works perfect, but I have 1 minor issue, hopefully
someone more family with javascript can help me out with.

1) the variables do not reset, so any future searches return the same
previous returned link, unless i clear settings/cookies.

Any help would be greatly appreciated.

First, I can't make out what you're trying to accomplish based on that
snippet. Where is it called from? What the heck is a <person> tag? etc.
Give us a URL where we can examine the code ourselves.

Second, try asking in comp.lang.javascript.
 
H

Harlan Messinger

CADD said:
I've used http://www.bloglines.com to add RSS feeds to my sites there
and setup javascript in my website to search bloglines for the input
term.

The code below works perfect, but I have 1 minor issue, hopefully
someone more family with javascript can help me out with.

1) the variables do not reset, so any future searches return the same
previous returned link, unless i clear settings/cookies.

When do you expect them to "reset", and why? There isn't anything here
to reset. You're declaring a bunch of variables, and defining them
explicitly with hard-coded values in the declaration.

The said:
{CODE}

<script language="JavaScript">
var name = "<person/>";
<![CDATA[
function Popup(){
var rssURL = "http://www.bloglines.com/search?q=";
var winWidth=800;
var winHeight=600;
var winScrollbars="yes";
var winToolbar="yes";
var winSizeable="yes";
var winLocation="yes";
var winDirectories="yes";
var winStatus="yes";
var winMenubar="yes";
var winCopyHistory="yes";
newWin=window.open(rssURL+name,"",
"copyhistory="+winCopyHistory+
",menubar="+winMenubar+
",status="+winStatus+
",directories="+winDirectories+
",location="+winLocation+
",resizable="+winSizeable+
",toolbar="+winToolbar+
",scrollbars="+winScrollbars+
",height="+winHeight+
",width="+winWidth);
}
]]>
</script>
<a href="javascript:popup()"><person/></a>
{END CODE}

Any help would be greatly appreciated.

CADD
 
J

Jonathan N. Little

Harlan said:
When do you expect them to "reset", and why? There isn't anything here
to reset. You're declaring a bunch of variables, and defining them
explicitly with hard-coded values in the declaration.

The <person/> thing is bizarre. What's that supposed to be?

It certainly isn't a JavaScript variable! Cannot see how this could ever
work!
 
C

CADD

wow - thank you all for the responses.

OK, I didn't fully explain what is going on.

This is being called through HTML. the input of the person is matched
with AIML "keywords", so to invoke the script, the user would type
something like "RSS baseball" and the <person/> tag is AIML to kickback
the input from the user following the keyword (baseball in this case)

so, the [var name = "baseball"; ] takes the input from the <person/>
and uses that as the value and adds it to the end of the URL
[newWin=window.open(rssURL+name,"", ]

this: <a href="javascript:popup()"><person/></a>

returnes a hyperlinked "baseball" and takes the user to the URL
[http://www.bloglines.com/search?q=baseball]

so, it all works perfectly now, except you have to clear your brower's
cookies to get the next search result, otherwise it just keeps
outputting the link with the previously assigned variables.

i would like the variables to terminate after the link is returned, but
they aren't.

thanks again for all the feedback.
 
C

CADD

<person/> is input from the user, so it would need to reset every time
the user typed in a new phrase.

that part works fine, but the variable retains that value and i would
like it to terminate the input once the link is returned.

the functionality of the script works flawlessly, just the variable
doesn't reset for new input unless you clear your browser settings.

var name = "<person/>" needs to reset every time i run the code,
without me having to clear my settings.

Harlan said:
CADD said:
I've used http://www.bloglines.com to add RSS feeds to my sites there
and setup javascript in my website to search bloglines for the input
term.

The code below works perfect, but I have 1 minor issue, hopefully
someone more family with javascript can help me out with.

1) the variables do not reset, so any future searches return the same
previous returned link, unless i clear settings/cookies.

When do you expect them to "reset", and why? There isn't anything here
to reset. You're declaring a bunch of variables, and defining them
explicitly with hard-coded values in the declaration.

The said:
{CODE}

<script language="JavaScript">
var name = "<person/>";
<![CDATA[
function Popup(){
var rssURL = "http://www.bloglines.com/search?q=";
var winWidth=800;
var winHeight=600;
var winScrollbars="yes";
var winToolbar="yes";
var winSizeable="yes";
var winLocation="yes";
var winDirectories="yes";
var winStatus="yes";
var winMenubar="yes";
var winCopyHistory="yes";
newWin=window.open(rssURL+name,"",
"copyhistory="+winCopyHistory+
",menubar="+winMenubar+
",status="+winStatus+
",directories="+winDirectories+
",location="+winLocation+
",resizable="+winSizeable+
",toolbar="+winToolbar+
",scrollbars="+winScrollbars+
",height="+winHeight+
",width="+winWidth);
}
]]>
</script>
<a href="javascript:popup()"><person/></a>
{END CODE}

Any help would be greatly appreciated.

CADD
 
C

CADD

the only variable that changes is [var name = "<person/>";]

<person/> is the input from user

so after </category>, that script is terminated.

the script does not run again unless the user enters the "keyword"
again.

when the user runs it again, then the new <person/> should be passed
through the javascript.

at the moment, <a href="javascript:popup()"><person/></a> says the
correct title for the URL, but when you click it, it takes you to the
last "keyword"
<person/> is input from the user, so it would need to reset every time
the user typed in a new phrase.

that part works fine, but the variable retains that value and i would
like it to terminate the input once the link is returned.

the functionality of the script works flawlessly, just the variable
doesn't reset for new input unless you clear your browser settings.

var name = "<person/>" needs to reset every time i run the code,
without me having to clear my settings.

Harlan said:
CADD said:
I've used http://www.bloglines.com to add RSS feeds to my sites there
and setup javascript in my website to search bloglines for the input
term.

The code below works perfect, but I have 1 minor issue, hopefully
someone more family with javascript can help me out with.

1) the variables do not reset, so any future searches return the same
previous returned link, unless i clear settings/cookies.

When do you expect them to "reset", and why? There isn't anything here
to reset. You're declaring a bunch of variables, and defining them
explicitly with hard-coded values in the declaration.

The said:
{CODE}

<script language="JavaScript">
var name = "<person/>";
<![CDATA[
function Popup(){
var rssURL = "http://www.bloglines.com/search?q=";
var winWidth=800;
var winHeight=600;
var winScrollbars="yes";
var winToolbar="yes";
var winSizeable="yes";
var winLocation="yes";
var winDirectories="yes";
var winStatus="yes";
var winMenubar="yes";
var winCopyHistory="yes";
newWin=window.open(rssURL+name,"",
"copyhistory="+winCopyHistory+
",menubar="+winMenubar+
",status="+winStatus+
",directories="+winDirectories+
",location="+winLocation+
",resizable="+winSizeable+
",toolbar="+winToolbar+
",scrollbars="+winScrollbars+
",height="+winHeight+
",width="+winWidth);
}
]]>
</script>
<a href="javascript:popup()"><person/></a>
{END CODE}

Any help would be greatly appreciated.

CADD
 
N

Nikita the Spider

OK, I didn't fully explain what is going on.

This is being called through HTML. the input of the person is matched
with AIML "keywords",

What's AIML?
so to invoke the script, the user would type
something like "RSS baseball" and the <person/> tag is AIML to kickback
the input from the user following the keyword (baseball in this case)

Yikes, this brings up more questions than it answers, but at least it
gives us a better idea as to what's happening.

You're skipping something important -- the user types "RSS baseball" and
then what does he do in order to signify, "I'm done typing now, please
act on this input"? CLick a submit button in an HTML form? Click a
button that has a Javascript onclick event? In any case, the problem
might be inside the action of the <person/> tag which I gather is
something that's defined in a another language (not HTML). You might
need to ask on a newsgroup that's specific to that language.
 
J

Jonathan N. Little

CADD wrote:
at the moment, <a href="javascript:popup()"><person/></a> says the
correct title for the URL, but when you click it, it takes you to the
last "keyword"

Whatever, one biggie problem is the pseudo-protocol "javascript:" should
not be used in an HREF attribute. The reasons have been listed countless
time in the NG. Research a bit on your own...


http://www.google.com/search?hl=en&q=javascript:+not+valid+href+protocol&btnG=Google+Search
javascript: not valid href protocol - Google Search
 
H

Harlan Messinger

[top-posting corrected]
CADD said:
> <person/> is input from the user, so it would need to reset every time
> the user typed in a new phrase.
>
> that part works fine, but the variable retains that value and i would
> like it to terminate the input once the link is returned.

How does it work fine, when "<person/>" is just a character string that
doesn't do anything? You must be using some underlying server-side
platform that does something with this, but it isn't HTML and it isn't
Javascript. Besides, you don't even show any form fields for a user to
enter input, so how can it be "input from a user"? All you have is

<a href="javascript:popup()"><person/></a>

which is a link that executes the function Popup()--if the user can find
it, because it won't show up on the page. That, in turn, is because the
> the functionality of the script works flawlessly, just the variable
> doesn't reset for new input unless you clear your browser settings.
>
> var name = "<person/>" needs to reset every time i run the code,
> without me having to clear my settings.

Every time, name will equal "<person/>". First time, every time. Because
that's what you're setting it to.
 
C

CADD

How does it work fine said:
doesn't do anything?
You must be using some underlying server-side
platform that does something with this, but it isn't HTML and it isn't
Javascript.

It's fine because AIML is and XML-variant that gets parsed on-the-fly
and the <person/> is being passed to the javascript as requested. It's
all done via HTML on the client-side.

Check it out for yourself if you'd like:

http://www.pandorabots.com/pandora/talk?botid=875d96ffae366536

Type: "RSS baseball"

Then try "RSS donuts"



Besides, you don't even show any form fields for a user to
enter input, so how can it be "input from a user"? All you have is

<a href="javascript:popup()"><person/></a>

which is a link that executes the function Popup()--if the user can find
it, because it won't show up on the page. That, in turn, is because the
only thing between the opening and closing A tags is a <person/> tag
that the browser won't recognize as HTML and will therefore ignore.

It shows up on the page and everything works smooth.

Exept for the fact the link you just clicked will be the same one,
unless you clear your internet browser.


I apologize in posting in the wrong forum, but i thought a java-guy
might be able to ignore some trivial code and possibly offer a solution


Harlan said:
[top-posting corrected]
CADD said:
<person/> is input from the user, so it would need to reset every time
the user typed in a new phrase.

that part works fine, but the variable retains that value and i would
like it to terminate the input once the link is returned.

How does it work fine, when "<person/>" is just a character string that
doesn't do anything? You must be using some underlying server-side
platform that does something with this, but it isn't HTML and it isn't
Javascript. Besides, you don't even show any form fields for a user to
enter input, so how can it be "input from a user"? All you have is

<a href="javascript:popup()"><person/></a>

which is a link that executes the function Popup()--if the user can find
it, because it won't show up on the page. That, in turn, is because the
the functionality of the script works flawlessly, just the variable
doesn't reset for new input unless you clear your browser settings.

var name = "<person/>" needs to reset every time i run the code,
without me having to clear my settings.

Every time, name will equal "<person/>". First time, every time. Because
that's what you're setting it to.
 
C

CADD

You're right, it does bring up a lot of questions, which I was trying
to keep all this as simple as possible from the beginning.

I wouldn't expect anyone here to know much about Artificial
Intelligence Markup Language [AIML], but it's just another variant of
XML and all is well on that end of things.

The beautiful thing about XML is it comes in many forms and integrates
with everything.

Yes, the user submits his input by pressing a button in an HTML form -
you can give it a try here:
http://www.pandorabots.com/pandora/talk?botid=875d96ffae366536

It's definitely something with the javascript example, the variable is
definitely making it through the script, but just not leaving when it's
the end of the function. It was my first attempt of putting together
javascript used for anything like that, so i can't say for sure that my
use of variables was appropriate.

If someone could ignore the rest of the stuff and help me put together
a better way of what i posted, I would be extremely grateful.
 
H

Harlan Messinger

CADD said:
It's fine because AIML is and XML-variant that gets parsed on-the-fly
and the <person/> is being passed to the javascript as requested. It's
all done via HTML on the client-side.

Check it out for yourself if you'd like:

http://www.pandorabots.com/pandora/talk?botid=875d96ffae366536

Type: "RSS baseball"

Then try "RSS donuts"

Besides, you don't even show any form fields for a user to

It shows up on the page and everything works smooth.

Exept for the fact the link you just clicked will be the same one,
unless you clear your internet browser.

I apologize in posting in the wrong forum, but i thought a java-guy
might be able to ignore some trivial code and possibly offer a solution

The "trivial code" involves a technology I never heard of and probably
has something to do with the problem. If I or anyone in a similar
position don't know the technology and therefore don't know the correct
way to use it, how are we supposed to tell you whether what you've done
is right or wrong?
 
C

CADD

only asking for help with the javascript, everything else seems to be
smooth sailing.

the var name takes input and doesn't get ride of it.

how can i get my variable to reset every time it is passed a variable?
 
N

Nikita the Spider

Yes, the user submits his input by pressing a button in an HTML form -
you can give it a try here:
http://www.pandorabots.com/pandora/talk?botid=875d96ffae366536

It's definitely something with the javascript example, the variable is
definitely making it through the script, but just not leaving when it's
the end of the function. It was my first attempt of putting together
javascript used for anything like that, so i can't say for sure that my
use of variables was appropriate.

Having looked at the example, I'm not sure what the problem is. I go to
the URL that you gave above, type in "rss baseball", hit enter, and I
get another screen that looks basically the same but with this added:
Human: rss baseball
botCAD: baseball.

On that page, it looks like the very top of the <script> block (var name
= " baseball";) was generated by a server-side process based on my
input. If the server-side process isn't writing the correct value into
that variable, then this isn't a Javascript problem and it isn't an HTML
problem, it is a problem with your server side code. Make sense?
 
C

CADD

Nikita,

Thanks again for the reply.

It makes sense what you're saying, but I do not believe it to be a
server-side error because the variable is actually assigned. When you
type baseball, it generates a link that says baseball and when you
click the link, it takes you to an RSS baseball search on bloglines. if
you go back and now type "RSS football", the link says football now,
but when you click it, it still takes you to the RSS baseball search.

any other thoughts?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top