1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Add values to a link and open it in the same window on submit

Discussion in 'JavaScript' started by qwikad.com, Mar 28, 2019.

  1. #1
    Let's say I have a link somesite.com/?q=

    I want to add some values to it (via inputs) and open it in the same window on submit. So the link will look like this when it opens: somesite.com/?q=Some Job Title Some Location Some Company Name

    1.png

    It probably should be done via a form with some javascript right? Or how would you do that?
    SEMrush

    Appreciate your help!
     
    qwikad.com, Mar 28, 2019 IP
    SEMrush
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    8,924
    Likes Received:
    1,625
    Best Answers:
    232
    Trophy Points:
    515
    #2
    You should not do this with client-side processing... you want to combine them to one field, do it SERVER-SIDE.

    You can kind-of cheat though:

    
    <label>City: <input name="q[]"></label>
    <label>Town: <input name="q[]"></label>
    <label>Zip: <input name="q[]"></label>
    
    Code (markup):
    Assuming PHP server-side, you could then just do:

    
    \\ assuming you checked that $_POST['q'] iss set and array first
    $q = implode(' ', $_POST['q']);
    
    Code (markup):
    It's a cute trick, if you have elements named [] PHP will treat them as a dynamic array.

    Again, not something you have any business screwing with using client-side scripting. Do it on the server.
     
    deathshadow, Apr 5, 2019 IP