Author |
Topic  |
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 25 February 2007 : 13:18:07
|
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
|
Querystring? I'm not great with client-side scripting (which I'm guessing the js above is) |
 |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 26 February 2007 : 12:40:05
|
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).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.” |
 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 26 February 2007 : 14:09:43
|
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 |
 |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 27 February 2007 : 06:51:47
|
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.” |
 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 27 February 2007 : 08:53:10
|
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 |
 |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 27 February 2007 : 09:32:39
|
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 |
 |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 27 February 2007 : 09:40:09
|
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.” |
 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 27 February 2007 : 10:00:35
|
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.” |
 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 27 February 2007 : 11:16:13
|
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.” |
 |
|
Podge
Support Moderator
    
Ireland
3776 Posts |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 12 March 2007 : 18:12:18
|
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 |
 |
|
Topic  |
|