...

View Full Version : concatenation problems...



DiarYofaMadmaN
08-17-2004, 01:26 PM
<select name="select" onChange="'location.href=CatID=3&SectionID=advanced-search&SearchID=' + document.form1.select.options[document.form1.select.selectedIndex].value + '.php'">

I don't know much about javascript but would like to learn as much as possible. I think there's a concatenation problem in the onChange... Can anyone help me out?

-Thanks

head8k
08-17-2004, 02:35 PM
I think this is what you are trying to do:



<script>
<!--
function changePage(picked){
newPage = 'http://www.whatever.com/'+picked+'.php';
eval(location.href=newPage);
}
-->
</script>


<select name="choose" onchange="changePage(this.options[this.selectedIndex].value)">
<option value="page1">1</option>
<option value="page2">2</option>
</select>

jbot
08-17-2004, 04:05 PM
<script>
<!--
function changePage(picked){
newPage = 'http://www.whatever.com/'+picked+'.php';
location.href=newPage;
//eval(location.href=newPage);
}
-->
</script>

you don't need the eval - that's just superfluous!

DiarYofaMadmaN
08-19-2004, 05:48 AM
I think this is what you are trying to do:



<script>
<!--
function changePage(picked){
newPage = 'http://www.whatever.com/'+picked+'.php';
eval(location.href=newPage);
}
-->
</script>


<select name="choose" onchange="changePage(this.options[this.selectedIndex].value)">
<option value="page1">1</option>
<option value="page2">2</option>
</select>


Thanks Head8k and jbot :-)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum