javascript split -


<script language="javascript"> function frompost() {   var string=$('#indexsearch').val();   var url=string.split('=');   if(url==""){   var url=string.split('video/');     }   var finalurl='http://watchvideos.tv/watch/'+url[1];   window.location = finalurl;   //$('#srchfrm').attr('action',finalurl);   //document.srchfrm.submit(); } </script> 

i have problem script - it's ok long indexsearch field contains = , fails when it's supposed work - video/ in field

try this:

function frompost() {   var str = $('#indexsearch').val(),       url = str.split(/=|video\//),       finalurl = 'http://watchvideos.tv/watch/'+url[1];   window.location = finalurl; } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -