Unfortunately, now it seems to prompt whenever I click the submit button, whether or not it actually equals "Department"?? However, this only happens when there is one row, if a user inserts another row or two it acts as it should.
You may use a single function... but, as, most of the time, a validation function is a "personalized" one, I need to know what kind of elements you need to validate and for what (empty values, lack of options' selection, numbers... and so on).
You may use a single function... but, as, most of the time, a validation function is a "personalized" one, I need to know what kind of elements you need to validate and for what (empty values, lack of options' selection, numbers... and so on).
I need to validate and ensure a selection has been made from the selection boxes in department[] and account[]. The default selection is "Department" and "Account" respectively.
I also have a input box named amount[], I would like to ensure there is a numeric value in this input.
Im not sure if you saw the last message (sorry if you did) but it seems the validation doesnt work correctly if there is only 1 row. Upon clicking submit it always prompts to select a value even if you have, however if you insert other rows it works as desired?
Yes, I have tried. I am really new to javascript but very good with PHP and MySQL, this is my first attempt to merge all 3 together. Sorry for the questions.
What I am saying right now, is the validation you helped me with doesnt work for the first set of inputs. However, if I choose to input another row of inputs, the validation works as desired. It seems as though the validation process is expecting a second row straight away.
The only other issue I had was having is adding more inputs to validate once it works. I dont need you to code it all out for me, I just need an example like you gave me that uses more than one. I have tried many different things that failed (last 2 days) but I didnt see the value in posting them.
Here is my relevant code after php has did its thing filling in values:
I have tried messing with the javascript but im unable to get it to work. Perhaps I should just scrap it as im not familiar with it and dont wont to keep bothering you guys.
function madeSelection(){
var names=['department[]','account[]'], n, sel, s, i, j=0;
while(n=names[j++]){
sel=document.getElementsByName(n); i=0;
while(s=sel[i++]){
if(s.selectedIndex==0){alert('Please Choose Something');s.focus();return false;}
}
}
}
I would just like to say thank you very much, you have really shown me some creative ways to do things, i have read up on some of these things and hopefully this can be a good starting point for me.
thanks again, im sorry if I was a bit persistent, hate it when I cant get something to work.
do you know a good book (or heck, have you written) one that specializes in javascript working with webforms, etc..?
Hi the example is working fine. But only one problem.
I want the options list as
<option value="item1" >item1</option>
<option value="item2">item2</option>
<option value="item3" selected="selected">item3</option>
<option value="item4">item4</option>
<option value="item5">item5</option>
"item 3 " shouldbe selected. But i tried n number way , always it is showint the selected item as "item1" (i.e. the one that present in the first option).
Ive been using this code and I have the need for something that seems so simple but yet so hard. I need to keep track of (and display) the number of the current row.
For example, when a user clicks to insert another row of elements, I would like to be able to display that it is Row 2, or Row 3. I have been unable to find a way to do this and display it in PHP, im thinking it is not possible?
Bookmarks