The title might not be clear, but I’ll explain it here. I’m a total newbie and I have almost no knowlege in JS, so please be clear.
My main code is here:
function goTo()
{
var url = "http://myurl.com/";
var name = document.forms[0].name.value;
window.location = url+name;
return false;
}
The code uses a set url and a form value, then if I press the send button, it jumps to the preset url + the form value.
But what I want, is to get just the last part of the input, so for example, this is my input:
http://lolsite.com/testing/files/HAfg76SDA
And I want the code to get the part of the input after the “/”, so the finished product would be “HAfg76SDA”. Now I want to snip this product at the end of my preset url, so when I press the submit button, it goes to:
http://myurl.com/HAfg76SDA
I would like to know if is this even possible, and if it is, I would nedd a code i could use straight away. Btw. I tried to use
function goTo()
{
var url = "http://myurl.com/";
var name = document.forms[0].name.value.(lastIndexOf("/")+1);
window.location = url+name;
return false;
}
but it doesn’t seem to work.
1 Answer