-1

Quick question! How can I add a semicolon before the value that is returned for

  onFormReady: function($form) {
    $('input[name="website"]').val(window.location.href).change();
  }

That returns that URL correctly, but I need a semicolon to appear before that value that is returned.

How can I do this?

Thanks.

1 Answers1

0

You can try this:

';' + $('input[name="website"]').val(window.location.href).change();
Dino
  • 7,779
  • 12
  • 46
  • 85
  • jQuery's [`.change()`](https://api.jquery.com/change/#change) does not return a string. It sounds like OP wants something more like `.val(';' + window.location.href)` – Phil Oct 06 '19 at 23:28
  • @Phil Did you just assume I use jQuery? –  Oct 06 '19 at 23:30
  • I assumed OP was using jQuery given the `$`, `.val()` and `.change()` – Phil Oct 06 '19 at 23:31
  • @Phil, .val(';' + window.location.href) is exactly what I needed. That worked. Thank you. – user3345500 Oct 06 '19 at 23:58
  • @Phil If I change window.location.href to window.location.pathname, it gives me the path only, which is great, but how can I extract only the final part of the path (i.e. everything after the final /)? – user3345500 Oct 07 '19 at 00:54
  • @user3345500 [Need a basename function in Javascript](https://stackoverflow.com/questions/3820381/need-a-basename-function-in-javascript) – Phil Oct 07 '19 at 00:56
  • Thanks. Will have to spend some time figuring out how to use that with the code in my original post. This is pretty foreign to me. Thank you for pointing me in the right direction. Is there any way to merge everything into my original code, like... window.location.pathname.split("/").pop() ...or some sort of merging of lastIndexOf within the code I already have? – user3345500 Oct 07 '19 at 01:11