Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

HTML Redirect

views
     
TSUbuntuClient
post Aug 20 2018, 05:55 PM, updated 6y ago

Regular
******
Senior Member
1,349 posts

Joined: Jun 2007
From: /puchong/cyberjaya/klang



Hi,

How to redirect using submit form? Let say when user put mobile number in form and submit it will include as example link.

myprivate.com/60114357896

Then it will open whatapp. Any idea how to do it? I'm not programming or expert.

Please advice.

Thanks.

This post has been edited by UbuntuClient: Aug 20 2018, 05:56 PM
WongGei
post Aug 20 2018, 06:11 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
https://faq.whatsapp.com/en/26000030/
TSUbuntuClient
post Aug 20 2018, 06:15 PM

Regular
******
Senior Member
1,349 posts

Joined: Jun 2007
From: /puchong/cyberjaya/klang



So what coding to put in html/php?
webbytrout
post Aug 21 2018, 12:52 AM

Getting Started
**
Junior Member
57 posts

Joined: Feb 2017
who the user send msg to ? lol

just use js or jquery get the input value and replace into part of the url, change the submit button event to redirect instead of the normal form submit

TSUbuntuClient
post Aug 21 2018, 01:04 PM

Regular
******
Senior Member
1,349 posts

Joined: Jun 2007
From: /puchong/cyberjaya/klang



QUOTE(webbytrout @ Aug 21 2018, 12:52 AM)
who the user send msg to ? lol

just use js or jquery get the input value and replace into part of the url, change the submit button event to redirect instead of the normal form submit
*
Can you show me some example? I'm not expert coding.
webbytrout
post Aug 21 2018, 02:11 PM

Getting Started
**
Junior Member
57 posts

Joined: Feb 2017
QUOTE(UbuntuClient @ Aug 21 2018, 01:04 PM)
Can you show me some example? I'm not expert coding.
*
CODE

<form id="wa_Form">
<input id="wa_number" type="number" name="number">
<input id="wa_msg" type="text" name="msg">

<button type="submit" id="wa_send">Send</button>
</form>



$(function(){

$('#wa_send').on('click', function(e){
 e.preventDefault();
 let number = $('#wa_number').val();
 let msg = $('#wa_msg').val();

 window.location.href= "https://wa.me/15551234567?text="+msg
});
});



bumpo
post Aug 21 2018, 02:21 PM

On my way
****
Junior Member
632 posts

Joined: Mar 2013


QUOTE(UbuntuClient @ Aug 20 2018, 05:55 PM)
Hi,

How to redirect using submit form? Let say when user put mobile number in form and submit it will include as example link.

myprivate.com/60114357896

Then it will open whatapp. Any idea how to do it? I'm not programming or expert.

Please advice.

Thanks.
*
lets use below example of a simple form.
for your requirement of "redirect" using user entered mobile number, it can be achieve by changing the form's action (url it will submit to) value to use the value that user entered for phone number.

bold part is the javascript that will change the form's action
the blue part is in case you need a fixed prefix. you can use relative or absolute values
the red part is where the value for phone number is obtained from

<form method="GET" action="foo" id="myform" onsubmit="this.action = 'hobo/' + document.getElementById('phone').value;">
<input type="text" id="phone" value="">
<input type="submit" id="mysubmit" value="click me">
</form>

This post has been edited by bumpo: Aug 21 2018, 02:23 PM

 

Change to:
| Lo-Fi Version
0.0111sec    0.38    5 queries    GZIP Disabled
Time is now: 28th March 2024 - 05:01 PM