PDA

View Full Version : Help inserting variable in the middle of a url



philt@prominent.ca
02-24-2010, 11:48 AM
I need help with some syntax,

I need to have the value of a drop down box inserted into the middle of a url string,

e.g.:

Selected Value in drop down box "OEM"

URL I needed: http://www.somesearch.com/search?value0=OEM%3type=boolean%3value2=otherval%3

As you can see I need to take the data of the selected entry in the list box and insert it into the middle of the url string in this example the data is "OEM"

Derek
02-24-2010, 01:17 PM
Depends how your working with the url. In your example, is OEM the only bit that changes?

If http://www.somesearch.com/search?value0= and %3type=boolean%3value2=otherval%3 are constant then you simply concat the 3 strings
Otherwise it could prove awkward if the url is aways changing - but im sure you know this already.

longedge
02-24-2010, 01:21 PM
You say "in this example" so I'm not sure that this is exactly what you want but something along the lines of -


turl="http://www.somesearch.com/search?value0=%3type=boolean%3value2=otherval%3"
len = String.Length(turl);
pos = String.Find(turl, "value0=", 1, false);
turlleft = String.Left(turl, pos+6)
turlright = String.Right(turl, len-(pos+6))
tnewurl = turlleft.."OEM"..turlright

p.s. - pipped at the post :)

Scriptonite
02-24-2010, 04:23 PM
Seems like you would need something more like this:



String = "http://www.somesearch.com/search?value0="..ComboBox.GetItemData("ComboBox1", ComboBox.GetSelected()).."%3type=boolean%3value2=otherval%3"



This would return a string with the Data from the combobox selection in the actual URL.