The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

2 Pages V  1 2 >  
Reply to this topicStart new topic
> Can HTML <Select> process a not found in list.
bowlesj
post Mar 31 2018, 07:37 AM
Post #1


Novice
**

Group: Members
Posts: 22
Joined: 11-June 15
Member No.: 22,710



Hi, I an trying to figure out if the HTML <Select> statement has a way to allow entry if the user wants to enter a valid item that is not in the list. I went to this page to find the attributes for the <select> statement and found nothing that answered the question. I kept looking around and still nothing. So what I am doing to get around this now is have another place where they can enter new data if the item they wan to enter is not in the list. The odds if the item being in the list are about 99.9% but I can't be 100% sure that a new item won't come in.

I wanted to edit the subject line to be "Can HTML <Select> process an item not found in list." but there seems to be no way to do it. Some forums allow it.

Thanks,
John

This post has been edited by bowlesj: Mar 31 2018, 07:38 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 31 2018, 10:26 AM
Post #2


.
********

Group: WDG Moderators
Posts: 7,867
Joined: 10-August 06
Member No.: 7



QUOTE(bowlesj @ Mar 31 2018, 02:37 PM) *

Hi, I an trying to figure out if the HTML <Select> statement has a way to allow entry if the user wants to enter a valid item that is not in the list.

Alas that's not possible.

QUOTE
what I am doing to get around this now is have another place where they can enter new data if the item they wan to enter is not in the list.

That sounds like the best solution.

QUOTE
I wanted to edit the subject line to be "Can HTML <Select> process an item not found in list." but there seems to be no way to do it. Some forums allow it.

You should be able to edit up to an hour after posting, see also http://forums.htmlhelp.com/index.php?act=boardrules
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bowlesj
post Mar 31 2018, 10:52 AM
Post #3


Novice
**

Group: Members
Posts: 22
Joined: 11-June 15
Member No.: 22,710



Thank you Christian J. I gave my users instructions on how to set the drop down back to "Chose an option" (press home then press tab). John
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 31 2018, 05:10 PM
Post #4


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,967
Joined: 9-August 06
Member No.: 6



I think this is something that has been wished for like forever. Something corresponding to a so called combo box in program interfaces.
https://en.wikipedia.org/wiki/Combo_box
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Apr 1 2018, 10:35 AM
Post #5


WDG Member
********

Group: Root Admin
Posts: 8,272
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE
So what I am doing to get around this now is have another place where they can enter new data if the item they wan to enter is not in the list.
That's what I've done. I just include an "Other" option in the select list, and next to the select list I include a text field labled "If Other, then specify:" or something like that.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bowlesj
post Apr 1 2018, 11:04 AM
Post #6


Novice
**

Group: Members
Posts: 22
Joined: 11-June 15
Member No.: 22,710



I attached a picture of what I did. I reduce the song names because it took the form size up to over a meg. Attached Image
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Apr 1 2018, 01:40 PM
Post #7


Programming Fanatic
********

Group: Members
Posts: 1,515
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



While HTML can't do it javascript can. A minimal sample is attached but it could be expanded. The entry is added when you leave the field. If you don't want to add an entry just leave the field blank and exit the field. It will not add duplicate entries. The problem with this method is that the newly added entry is not saved. If you have a database where these values come from then you could use AJAX to add the entry to the database.
Attached File  combobox.html ( 2.48k ) Number of downloads: 103
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bowlesj
post Apr 1 2018, 02:38 PM
Post #8


Novice
**

Group: Members
Posts: 22
Joined: 11-June 15
Member No.: 22,710



QUOTE(CharlesEF @ Apr 1 2018, 02:40 PM) *

While HTML can't do it javascript can. A minimal sample is attached but it could be expanded. The entry is added when you leave the field. If you don't want to add an entry just leave the field blank and exit the field. It will not add duplicate entries. The problem with this method is that the newly added entry is not saved. If you have a database where these values come from then you could use AJAX to add the entry to the database.
Attached File  combobox.html ( 2.48k ) Number of downloads: 103



Thank you CharlesEF. That is an interesting idea. I guess the new entry replaces the "Add Manufacturer" entry. I use PHP. it could pick up the info and add it. John
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Apr 1 2018, 04:12 PM
Post #9


Programming Fanatic
********

Group: Members
Posts: 1,515
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(bowlesj @ Apr 1 2018, 02:38 PM) *
Thank you CharlesEF. That is an interesting idea. I guess the new entry replaces the "Add Manufacturer" entry. I use PHP. it could pick up the info and add it. John
No, the "Add Manufacturer" entry should always be available. The new entry is added to the end of the select options, so you can keep adding manufacturers. Where do the values for the select options come from? Do you fill the select options with the results of a database query?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bowlesj
post Apr 1 2018, 04:38 PM
Post #10


Novice
**

Group: Members
Posts: 22
Joined: 11-June 15
Member No.: 22,710



QUOTE(CharlesEF @ Apr 1 2018, 05:12 PM) *

QUOTE(bowlesj @ Apr 1 2018, 02:38 PM) *
Thank you CharlesEF. That is an interesting idea. I guess the new entry replaces the "Add Manufacturer" entry. I use PHP. it could pick up the info and add it. John
No, the "Add Manufacturer" entry should always be available. The new entry is added to the end of the select options, so you can keep adding manufacturers. Where do the values for the select options come from? Do you fill the select options with the results of a database query?


Okay thanks, that makes sense now that you mention it. To answer your question I am doing something unusual because I have a very small user group (10 to 20). I had a full blown mysql website on a VPS as normal but it failed to become popular enough to make it worth keeping. So I downsized it to my interest "jazz" creating a Jazz Karaoke Jam group. Instead of going through the hassle of putting the data on the server, teaching them to do all the extra work (and risking turning them off) etc I decided to keep the mysql database on my xampp at home and just send up the static html/javascript spages (I right click and save them to my machine then send them up with winSCP.). I only have two php pages and it took me a long time to find out I could run php on my hosting account without having a VPS. Finding this out is why I went ahead and created the revised php pages. One page is to receive the info from the form and format an email to myself which I use to update my database at home. This keeps me in direct contact with my users (my friends now) since I am the one running the jams and playing at them too. It works better for now. So to get back to your question the songs and the fake books are loaded from my xampp based mysql database at home.

I am not very advanced at this stuff. I have programmed for 37 years but only recently did I teach myself enough (html, php, javascript, mysql and a few other languages) to get my two website(s) up. Anything new I have not done before often takes me a day to figure out via google searches. Getting the combo box in a table was one of these. If you care to you can see my recent struggle to put a drop down box in a table at this link. I finally at least 4 hours later figured it out on my own with a certain type of google search that found an example.

This post has been edited by bowlesj: Apr 1 2018, 04:48 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Apr 1 2018, 05:54 PM
Post #11


Programming Fanatic
********

Group: Members
Posts: 1,515
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



You could use AJAX to send the new select entry to the PHP page that e-mails you the information. Then you can add it to your database.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bowlesj
post Apr 1 2018, 06:06 PM
Post #12


Novice
**

Group: Members
Posts: 22
Joined: 11-June 15
Member No.: 22,710



QUOTE(CharlesEF @ Apr 1 2018, 06:54 PM) *

You could use AJAX to send the new select entry to the PHP page that e-mails you the information. Then you can add it to your database.


Interesting. AJAX was one of the extra languages I didn't learn :-) However you have me thinking. Could I not capture the new data which is not in the select statement and which they put in a popup textbox that unhides itself as done through some javascript then put this value into the table cell by replacing the whole select item with all its options. At the same time I could have 14 hidden table rows (in a column) and dump the new item in there in the same row. So when the form is sent down to my PHP script I would loop this hidden column and include it in the mailing and this way I could know it was new and I could add it manually.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Apr 1 2018, 08:10 PM
Post #13


Programming Fanatic
********

Group: Members
Posts: 1,515
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



AJAX is nothing more than javascript. But yes, you could expand on the code to do what you want. The code could also add a table row to place the new entry in.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bowlesj
post Apr 1 2018, 08:17 PM
Post #14


Novice
**

Group: Members
Posts: 22
Joined: 11-June 15
Member No.: 22,710



QUOTE(CharlesEF @ Apr 1 2018, 09:10 PM) *

AJAX is nothing more than javascript. But yes, you could expand on the code to do what you want. The code could also add a table row to place the new entry in.


Okay, thanks CharlesEF. When I getting it working I will post the results and how I did it here :-) Don't expect it tomorrow :-)

This post has been edited by bowlesj: Apr 1 2018, 08:17 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bowlesj
post Apr 2 2018, 05:14 AM
Post #15


Novice
**

Group: Members
Posts: 22
Joined: 11-June 15
Member No.: 22,710



Hi CharlesEF, I am not sure if this is the correct place for this question but seeing as you brought up the topic of AJAX I thought I would ask it here. Actually anyone could answer this about any solutions to this issue.

The regular javascript popups which have this wonderful feature of being able to stop the javascript code such that when the user clicks the popup the code continues directly below it have one shortcoming. Specifically we can not customize them and they are very tiny and I personally prefer they come up in the middle of the screen. So I managed to get some jquery assistance and I have some popups that have larger print, a nice heading and they come up in the middle of the screen plus they have a scroll bar-slider on the right. Unfortunately these popups do not stop the code and continue inline which in certain situations causes me to just not bother using them. So does AJAX have a way to get the best of both of these worlds (popups that both stop the code and can be customized with larger fonts, scroll down for large amounts of text, whatever). I am sure this is another problem that many have asked for a fix on. I would probably want to learn a language that can do this. I avoid jquery. I have learned varying amounts of 17 languages over my 37 years and jquery I find to be very confusing while the rest are extremely easy to understand.

Thanks,
John

This post has been edited by bowlesj: Apr 2 2018, 05:18 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Apr 2 2018, 10:28 AM
Post #16


Programming Fanatic
********

Group: Members
Posts: 1,515
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



AJAX means 'Asynchronous JavaScript and XML' and it has nothing to do with display. It basically lets you send data to the server for processing and then returns the results.

If I understand you correctly you want to make a popup dialog where the user can enter the new select entry. This might mean you have many selects and want only 1 popup to allow new entries in any one of them?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bowlesj
post Apr 2 2018, 01:38 PM
Post #17


Novice
**

Group: Members
Posts: 22
Joined: 11-June 15
Member No.: 22,710



Thanks CharlesEF.

Regarding your question below.
QUOTE
If I understand you correctly you want to make a popup dialog where the user can enter the new select entry. This might mean you have many selects and want only 1 popup to allow new entries in any one of them?

I am assuming you are referring to my big paragraph question in my prior post. If that is correct It sounds like I need to explain it better. Here goes.

In the javascript below I show the Okay/Cancel confirm popup which I am sure everyone knows very well. The code stops and waits such that I can set the txt variable immediately after I initiate the popup (as opposed to the Asynchronous jquery I have been using which requires I create a function somewhere else to process the Okay answer and there is actually no way to process the No answer since the code keeps going after the prompt is presented to the user.". So the popup below works exactly the way it works in Micrsoft Access (the database program which runs Visual Basic For Applications). In that Micrsoft Access tool (which I know very very well) you can design forms, size the buttons, and do a lot of other stuff such as deciding where the popup will appear on the screen. Unfortunately Javascript's prompt below can do none of this. Jquery can do this but Jquery seems to be a very difficult language that requires a lot of time to fully master (more time that I have available to me). I am not sure if there is a way to get Jquery to process the No answer the way Javascript can do (meaning I am not sure if there is a way for Jquery to stop the code and wait for the user response). Hopefully I explained the question properly this time.

CODE

<script>
function myFunction() {
    var txt;
    if (confirm("Press a button!")) {
        txt = "You pressed OK!";
    } else {
        txt = "You pressed Cancel!";
    }
    document.getElementById("demo").innerHTML = txt;
}
</script>


This post has been edited by bowlesj: Apr 2 2018, 01:39 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Apr 2 2018, 03:26 PM
Post #18


Programming Fanatic
********

Group: Members
Posts: 1,515
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(bowlesj @ Apr 2 2018, 01:38 PM) *

In the javascript below I show the Okay/Cancel confirm popup which I am sure everyone knows very well. The code stops and waits such that I can set the txt variable immediately after I initiate the popup (as opposed to the Asynchronous jquery I have been using which requires I create a function somewhere else to process the Okay answer and there is actually no way to process the No answer since the code keeps going after the prompt is presented to the user.". So the popup below works exactly the way it works in Micrsoft Access (the database program which runs Visual Basic For Applications). In that Micrsoft Access tool (which I know very very well) you can design forms, size the buttons, and do a lot of other stuff such as deciding where the popup will appear on the screen. Unfortunately Javascript's prompt below can do none of this. Jquery can do this but Jquery seems to be a very difficult language that requires a lot of time to fully master (more time that I have available to me). I am not sure if there is a way to get Jquery to process the No answer the way Javascript can do (meaning I am not sure if there is a way for Jquery to stop the code and wait for the user response). Hopefully I explained the question properly this time.

CODE

<script>
function myFunction() {
    var txt;
    if (confirm("Press a button!")) {
        txt = "You pressed OK!";
    } else {
        txt = "You pressed Cancel!";
    }
    document.getElementById("demo").innerHTML = txt;
}
</script>

Javascript itself is asynchronous, not just jQuery. The reason your code stops and waits is because of the 'confirm' command. Javascript itself doesn't wait for anything, unless you put code in to waste time. jQuery is nothing more than a library of Javascript commands put together in a way that provides the users new methods to run code.

I admit I'm a bit confused. You say you can't process the 'Cancel' choice. Your code doesn't show any more commands to execute. So how do you process the 'Ok' answer? I can suggest different things but without understanding your problem I might make it worse. But here goes anyway (air code, not tested):
CODE
<script>
function myFunction() {
    var ans = confirm("Press a button!");
    switch(ans) {
     case 0:
       document.getElementById("demo").innerHTML = "You pressed Cancel!";
       //  code to execute when 'No' is clicked
       break;
     case 1:
       document.getElementById("demo").innerHTML = "You pressed OK!";
       //  code to execute when 'Yes' is clicked
       break;
    }
}
</script>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Apr 2 2018, 03:39 PM
Post #19


Programming Fanatic
********

Group: Members
Posts: 1,515
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Oh, if you want to stick with your approach how about this:
CODE
<script>
function myFunction() {
    var txt, ans;
    if (confirm("Press a button!")) {
        txt = "You pressed OK!";
        ans = true;
    } else {
        txt = "You pressed Cancel!";
        ans = false;
    }
    document.getElementById("demo").innerHTML = txt;
    if(ans)
    {
      \\ code to run when OK clicked
    }
    else
    {
      \\ code to run when Cancel clicked
    }
}
</script>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bowlesj
post Apr 2 2018, 06:20 PM
Post #20


Novice
**

Group: Members
Posts: 22
Joined: 11-June 15
Member No.: 22,710



Thanks for the examples. I understand what you did in all your code examples.

Your not understanding my question is starting make me think that the jquery code I was given may have been written incorrectly relative to what I was looking for (a popup that could continue the code below the initiation of the popup). Maybe you have never seen a jquery popup written like the one I was given. I had asked a simple question (if there were examples of how jquery could put a checkbox on the popup to cause the popup to not come back and repeatedly bother the user) and he just up and wrote it giving me the example. I attached picture of the popup for yes/no that he created and I learned to work with. It looks exactly like what I was looking for (centered in the screen, much larger print, a nice overall look, a checkbox to turn it off, just a really nice design). Except for one problem. You can't write code directly underneath it. So to explain what I mean by that I took your example and I put a comment off to the right (the comment has a bunch of arrows like this <<<<<<). If you want to see his jquery code and how I call it in JavaScript I can send everything including a test call page built in php. It is pretty extensive. All I will say at this point is I had to write what I gather is called a "call back function" to deal with the processing after the user clicked yes or no. Using this technique is not too cumbersome if you have only one of these user prompts alone. It becomes a nightmare if you have 2 or more in a row (inline). The reason it is very cumbersome is you have to put the next user prompt inside the callback function of the previous user prompt (and on and on and on for each new user prompt).

Attached Image


CODE
<script>
function myFunction() {
    var ans = confirm("Press a button!");   //<<<<<<<<<<<<<This is the call to the javascript function that provides the user prompt
    switch(ans) {    //<<<<<<<<<<<<<<<<<<<<<<<<<<<This is the code that runs directly under it when the user enters okay or cancel
     case 0:
       document.getElementById("demo").innerHTML = "You pressed Cancel!";
       //  code to execute when 'No' is clicked
       break;
     case 1:
       document.getElementById("demo").innerHTML = "You pressed OK!";
       //  code to execute when 'Yes' is clicked
       break;
    }
}
</script>


This post has been edited by bowlesj: Apr 2 2018, 06:39 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

2 Pages V  1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 15th August 2018 - 02:23 AM