Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Java Script Pop Up Message

Featured Replies

Hi guys,

 

So i got this problem with my form. It's a simple form for subscribing to a part of my website.

 

Basically the form consists of 2 input fields, one is 'Name' and the other is 'Email Address'

and the submit button is an image.

 

The problem I have is at the bottom of my form I have two options:

 

<label><input type="radio" name="subscription_status" value="radio" id="subscription_status_0")>Subscribe</label>

 

(This selection is for users to Subscribe to the service) and next i have:

 

<label><input type="radio" name="subscription_status" value="radio" id="subscription_status_1")>Subscribe</label>

 

(This selection is for users to Unsubscribe to the service)

 

What i want to do is if the user selects the "Subscribe" option and then his submit I want a message to popup saying something like "Thank you for subscribing".

 

However if the user selects the "Unsubscribe" option and then hits submit I want a message to popup saying something like "Your subscription has been canceled".

 

At the moment I can only work out how to get one message to popup when you hit the submit button. I need to understand how i can display the right message for the right selection.

 

I hope someone can help us out on this one, I'm really new to java script so please go easy on me!

 

Many thanks.

  • Author

At the moment I just a have simple alert message because i not sure how to write the code for the 2nd option (An unsubscribe message).

 

On the form I have:

onClick="MM_popupMsg('Thank you for subscribing!')"

 

and in the head i have this simple code:

<script type="text/javascript">function MM_popupMsg(msg) {
alert(msg);}</script>

 

But as you can see this code is kind of useless because if the user checks the other option (unsubscribe) and submits the form, on click they get the message "Thank you for subscribing!".

 

I hope this makes sense, thank you for your interest.

  • Author

Sorry just noticed a slight error on my first post, i meant to say this:

 

<label><input type="radio" name="subscription_status" value="radio" id="subscription_status_0")>Subscribe</label>

(This selection is for users to Subscribe to the service) and next i have:

<label><input type="radio" name="subscription_status" value="radio" id="subscription_status_1")>Unsubscribe</label>

(This selection is for users to Unsubscribe to the service)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.