Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Actually javascript used in asp...
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

ILLHILL
Junior Member

Netherlands
341 Posts

Posted - 25 February 2007 :  13:18:07  Show Profile
Hi, this is the script part:

function call_server()
{
request.open("GET", "page.asp");
request.onreadystatechange = sever_interaction;
request.send('');
}


The request.send must be able to send a variable to the asp page loaded in request.open

Here's the body part, which is a selectbox:

<select name="selector">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>

And the button:
<input type="button" name="Button" value="Button" onclick="call_server();" />


How can I have the button send along the selected value to the call_server script?


Appreciate any help.

Greets & thanks,

Dominic


CLPPR.com - All The News Only Seconds Away

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 26 February 2007 :  12:01:05  Show Profile  Send pdrg a Yahoo! Message
Querystring? I'm not great with client-side scripting (which I'm guessing the js above is)
Go to Top of Page

Podge
Support Moderator

Ireland
3776 Posts

Posted - 26 February 2007 :  12:35:50  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Untested but something like this...
function call_server()
{
var x=document.getElementById("selector")
request.open("GET", "page.asp?selected=" + x.selectedIndex);
request.onreadystatechange = sever_interaction;
request.send('');
}

<select name="selector" id="selector">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>


Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 26 February 2007 :  12:40:05  Show Profile
Give your select an id of selector and then modify the send function to pass through the value (where variable is whatever you want the variable name to be).
request.send("variable="+document.getElementById("selector").options[document.getElementById("selector").selectedIndex].value)
The argument of the send function is just like a querystring so, to pass more things through to the other script, you just need to use a=b&x=y&p=q, and so forth.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

ILLHILL
Junior Member

Netherlands
341 Posts

Posted - 26 February 2007 :  14:09:43  Show Profile
I will start with this now. Feedback might take some cause the flue is keeping my brain a clouded
mess, so I will probably overlook some very, very obvious things before I get it to work :)

Ps is it possible to have the options being links?

Thanks!

D

CLPPR.com - All The News Only Seconds Away

Edited by - ILLHILL on 26 February 2007 14:23:28
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 27 February 2007 :  06:51:47  Show Profile
quote:
Originally posted by ILLHILL
Ps is it possible to have the options being links?
You mean have the form submit once one of the options is selected? Technically speaking, that would be improper usage of the select tag and also causes problems for your visitors if they accidentally selected the wrong option. That being said, to achieve this, first give your form an ID (for the purposes of this example, I'll use selectorform) then add the following event to the opening select tag:
onchange="document.getElementById('selectorform').submit"
Even with this script, you should leave a submit button in the form for those that may have javascript disabled.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

ILLHILL
Junior Member

Netherlands
341 Posts

Posted - 27 February 2007 :  08:53:10  Show Profile
I meant, I have tried to have the options being links to rss feeds. (example: http://www.anywhere.something/feed.rss_or_xml_or_asp_or_php

Then the loaded page is a feedparser, so when the option is selected, that specific url
will be loaded as a variable into the feedparser page which then uses the selected feed
to parse.

This however does not seem to work (yet).

I did read of security functions in some scripts that prevent links due to certain characters,
but no idea if it applies here.

Greets & thanks,

Dominic

CLPPR.com - All The News Only Seconds Away

Edited by - Podge on 27 February 2007 08:57:07
Go to Top of Page

Podge
Support Moderator

Ireland
3776 Posts

Posted - 27 February 2007 :  09:00:38  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Is this what you want to do (bottom left)

http://momche.net/publish/article.php?page=rssload

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ILLHILL
Junior Member

Netherlands
341 Posts

Posted - 27 February 2007 :  09:32:39  Show Profile
Basically, yes that's what I want it to do (I also want to expand it with a text field where you can enter your own link if a feed is not in the list.

I have come to here:
http://www.illhill.com/IndexTestXalt2.asp

It loads the CNN feed on default, but that's where it ends.
Originally the select-box was not there and when the button
was clicked it automatically loaded the BBC feed (which worked
like a charm but basically allowed you to switch from CNN to BBC and not even back to CNN again).

The code I now have, in the body, is:


<form>
<select name="selector" id="selector">
<option value="http://rss.cnn.com/rss/cnn_topstories.rss" selected>CNN.com</option>
<option value="http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml">BBC.com World</option>
<option value="http://www.msnbc.msn.com/id/3097895/device/rss/rss.xml">MSNBC.com</option>
</select>
<input type="button" name="Button" value="Button" onclick="call_server();" />
</form>


which then loads the javascript:


function call_server()
{
request.open("GET", "Feedplugin.asp");
request.onreadystatechange = sever_interaction;
request.send("n_v="+document.getElementById("selector").options[document.getElementById("selector").selectedIndex].value
);
}

I have experimented with:
request.send("?n_v="
request.send("n_v"
request.send("Value_Rss"
and none of them succesful



The feedplugin.asp page starts with extracting the n_v value:


n_v = Request.QueryString("n_v")
if n_v = "" then Request.Cookies("n_v")
if n_v = "" then Value_Rss = "http://rss.cnn.com/rss/cnn_topstories.rss"
if n_v <> "" then Value_Rss = n_v


The feedplugin page also gets loaded into the div at the load of the page and because the
n_v value is empty, it will then load the cnn feed. However, when any of the other feeds is
selected nothing happens.


CLPPR.com - All The News Only Seconds Away

Edited by - ILLHILL on 27 February 2007 09:34:56
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 27 February 2007 :  09:40:09  Show Profile
You're missing the } to close off the sever_interaction function and you've also misspelled create_Object() when calling it to assign a value to the request variable.

To switch feeds when selecting an option rather than when clicking the button, ignore my post above and simply add the following event to the opening select tag:

onchange="call_server()"


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

ILLHILL
Junior Member

Netherlands
341 Posts

Posted - 27 February 2007 :  09:50:35  Show Profile
Thanks! Overlooked those two :( (Can I still blame the flu? ;)

CLPPR.com - All The News Only Seconds Away
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 27 February 2007 :  10:00:35  Show Profile
Another error: x.selectedIndex should be:

x.options[x.selectedIndex].value


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

ILLHILL
Junior Member

Netherlands
341 Posts

Posted - 27 February 2007 :  11:01:02  Show Profile
That was the last part! It now works like a charm.

Thanks Shaggy & Podge!

Greets & thanks, Dominic

CLPPR.com - All The News Only Seconds Away
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 27 February 2007 :  11:16:13  Show Profile
You're welcome


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

Podge
Support Moderator

Ireland
3776 Posts

Posted - 27 February 2007 :  11:49:04  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Ditto. Looks cool.

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ILLHILL
Junior Member

Netherlands
341 Posts

Posted - 12 March 2007 :  18:12:18  Show Profile
Sorry guys, I got a bit stuck. I want to make the javascript more dynamic to prevent the .js file from getting huge and loading slowly.

What I'm looking for is something along these lines:

I have this in a button:

onClick="var z = '01'; call_server()"


Which then is supposed to load call_server function, as well as send along the 01 value for var z:


function call_server(){
var x=document.getElementById("selector")
request.open("GET", "PluginPage" + escape(z) + ".asp?url=" + x.options[x.selectedIndex].value)
request.onreadystatechange = sever_interaction;
request.send('');
}

I have a couple PluginPage files (PluginPage01.asp, PluginPage02.asp etc.), so with the Z var
I'm trying to dynamically load a specific page. (In this example it will load PluginPage01.asp)
From the CallServer function it is supposed to go along to sever_interaction and take a long
the var z value (in this case "01"):


function sever_interaction()
{
if(request.readyState == 1)
{
document.getElementById(escape(z)).innerHTML='';
document.getElementById(escape(z)).innerHTML = 'loading...';
}
if(request.readyState == 4)
{
var answer = request.responseText;
document.getElementById(escape(z)).innerHTML='';
document.getElementById(escape(z)).innerHTML = answer;
}
}

This code decided in which div id the script should load (which should be div id 01).


Where am I going wrong? Is the onclick function correct? Is it easier to give the button used
for the onclick an id and make that id 01 (or 02, 03 where appropriate)?


I have a feeling that I'm almost there (I actually was ready to launch this app till it slowed
down dramatically because I had multiple call_server and sever_interaction functions for the
different categories).

Anybody spots my flaws?

Greets & thanks in advance,

Dominic

CLPPR.com - All The News Only Seconds Away
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000 Version 3.4.07