...

View Full Version : Passing a value from combobox to text link



SpiderWoman
12-12-2007, 07:10 PM
Hi all,
Here is what I'm trying to do and can't find the code for it anywhere..

Combo box with integer values, ie

<select name="monthIDs">
<option value="">select month
<option value="1">January
<option value="2">February
... etc
</select>

Next to the combo I want a link *view details* That opens a popup window with content specific to the selected month.

I do not want to submit the form, but allow the viewer to see what is in each of the months just by selecting the month from the combo and then click on the link next to it.

Any ideas of where to look?

TIA
Spidey

oesxyl
12-12-2007, 07:31 PM
take a look at this demo, maybe is what you want:

http://www.xul.fr/en-xml-ajax.html#ajax-get-body

best regards

SpiderWoman
12-12-2007, 07:46 PM
Yes and no. I know how to pass a simple text value with Javascript, but I need to pass the value to a link. It can be done with simple Javascript, but for the life of me I haven't been able to get it to work.

oesxyl
12-12-2007, 08:06 PM
Yes and no. I know how to pass a simple text value with Javascript, but I need to pass the value to a link. It can be done with simple Javascript, but for the life of me I haven't been able to get it to work.

A simple text value could be computed or a piece of code, :D



'<a href="http://your.link/page?arg=' + value + '">your link text</a>'

SpiderWoman
12-12-2007, 08:22 PM
:) getting there...
now complicating this... this is what I have now...



<html>
<head>
<title>Set Message</title>
<script language="JavaScript">
myarr=new Array()
myarr[1]='<a href="includes/inc_viewrule.cfm?rulesid=1">your link text</a>'
myarr[2]='<a href="includes/inc_viewrule.cfm?rulesid=2">your link text</a>'
myarr[3]='<a href="includes/inc_viewrule.cfm?rulesid=3">your link text</a>'
myarr[4]='<a href="includes/inc_viewrule.cfm?rulesid=4">your link text</a>'
myarr[5]='<a href="includes/inc_viewrule.cfm?rulesid=5">your link text</a>'
function doIt(objval)
{
document.getElementById("msg").innerHTML=myarr[objval]
}
</script>
</head
<body>
<form name="myform">
<select name="searchin" onChange="doIt(this.options[this.selectedIndex].value)">
<option value="1">First link</option>
<option value="2">Second link</option>
<option value="3">Third link</option>
<option value="4">Fourth link</option>
<option value="5">Fifth link</option>
</select>
<span id="msg">First link</span>
</form>
</body>
</html>

This works OK. Now if I want to show the popup window as a greybox, the code that I use for that won't work now..

This is the normal <a href> code for it


<a href="includes/inc_viewrule.cfm?rulesid=1" onclick="return GB_show ('View Rule', 'includes/inc_viewrule.cfm?rulesid=1', 650, 650)" style="text-decoration:underline;">

I've removed the dynamic variables from it to make it look simpler. When I put that in instead of the *plain* link, the text won't change and therefore the link won't show up either.

Any ideas?

oesxyl
12-12-2007, 09:08 PM
check this, and tell me if is what you expect:

http://sort-of.homelinux.org/combotest.html

I could be wrong but I think it work.

SpiderWoman
12-12-2007, 10:42 PM
check this, and tell me if is what you expect:

http://sort-of.homelinux.org/combotest.html

I could be wrong but I think it work.

That is pretty much it and I have that working as well, but once you change the link to open a greybox link, then the problems start :(

oesxyl
12-12-2007, 11:48 PM
That is pretty much it and I have that working as well, but once you change the link to open a greybox link, then the problems start :(
what kind of problem?

As far I see from my server log:

In errror log:

"File does not exist: .../includes/inc_viewrule.cfm"

In access log is a request:

"GET /includes/inc_viewrule.cfm?rulesid=5"


the error is normal and the rulesid=5 is passed to the server so I guess it work, :D

The only thing I have done was to escape the "'" and assign the myarr array with your link



myarr[1]='<a href="includes/inc_viewrule.cfm?rulesid=1" onclick="return GB_show (\'View Rule\', \'includes/inc_viewrule.cfm?rulesid=1\', 650, 650)" style="text-decoration:underline;">

best regards

SpiderWoman
12-13-2007, 01:17 AM
THAT WORKS!!!!! I could kiss you right now :)

You saved my evening :)

oesxyl
12-13-2007, 04:59 AM
THAT WORKS!!!!! I could kiss you right now :)

You saved my evening :)

:thumbsup:, I'm glad to help.

best regards

oesxyl
01-14-2008, 12:26 PM
check this, and tell me if is what you expect:

http://sort-of.homelinux.org/combotest.html

I could be wrong but I think it work.

Edit: 01/14/2008 - I remove content of the link, because is useless, from the server, and the red link from post #6 and #7 is invalid, see #5 and #8 from this thread for solution, read all thread or post a specific question.

shyam
01-14-2008, 12:42 PM
though the thread is a month old...i couldn't help :| but notice the misguided usage of an array


function doIt(objval)
{
document.getElementById("msg").innerHTML='<a href="includes/inc_viewrule.cfm?rulesid='+objval+'">your link text</a>';
}

is all you need



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum