1

I have a form where I am submitting data into database. There are following field:

FileName
Choose Image
Button

I am calling this form through URL e,g, https://www.w3schools.com

Now how can I hit button with parameter for example if I add paramaters for fields Like https://www.w3schools.com?id=1&name=abc&age=2

How can do for button and image.

https://www.w3schools.com?id=1&name=abc&age=2&buton=submit&chooseImage=img.png

Nothing Shows

mplungjan
  • 169,008
  • 28
  • 173
  • 236
kamran ijaz
  • 105
  • 1
  • 4
  • 14
  • I am not sure what you want. submitting the form so parameter are in the url?
    ...
    – Dieter Kräutl Sep 19 '19 at 11:36
  • 1
    You are not calling a form through a URL, You load a page that may have a form OR you call a server process using a GET request from the location bar. If you have a form, the form needs the action "/someaction" and have fields with names and values like `` You can then use method POST or GET (default). You CANNOT send an image using GET – mplungjan Sep 19 '19 at 11:36
  • Without at least the form as code in your question its hard to tell what you want. – Dieter Kräutl Sep 19 '19 at 11:37
  • You cannot trigger a form submit on a page using a URL to that page. You need a userscript or a server proxy – mplungjan Sep 19 '19 at 11:42

2 Answers2

3

To have parameters sent through the URL you need your form to be sent with GET method:

<form name="someName" action="https://www.w3schools.com" method="get">
...
</form>

You cannot sent image via get, but you can send the image name

Figaro Cat
  • 103
  • 8
0

Below script pass URL with a parameter (form field data).

$('.filterForm').on('submit',function(e){
  e.preventDefault();
  var formData=$(this).serialize();
  var fullUrl = window.location.href;
  var finalUrl = fullUrl+"&"+formData;
  window.location.href = finalUrl;
  alert(finalUrl);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<form class="filterForm" >
<input type="text" name="serialNumber" />
    <input type="submit" value="Submit" />
</form>
Shivasagar
  • 185
  • 1
  • 2