Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-10-2003, 05:20 PM   PM User | #1
Uncle Ron
New Coder

 
Join Date: Jan 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Uncle Ron is an unknown quantity at this point
Exclamation to beetle, responding to symptons not problem.

First, let me ask you, how do I keep this thread going? I seem to fall out of it when I try to respond to your suggestions.

Second, you may be right. But this is how I see it (I'm an old timer with experience in COBOL and a wonderful database system called PICK, so I'm trying my hardest to change my ways.)

When the script is requested all values are null. When the onChange is executed all three of the submit buttons are still null. I need a way to make update2 something other than null, like '1', for instance.

Then when the form is submitted, update1 will be null, update2 will be 1 and exit will be null. That way the PERL script will "know" that a request to retreive a group from the database has been submitted.

In the main script (masterFiles.cgi) the update codes are processed as follows: when update1 = 1, the script updates the data base, when update2 = 1 then the script retrieves the requested member of the data base and when exit = 1 then the script exits to the menuMaster.cgi (usually).

If my thinking is not too muddled, I think I need a function that will, onChange, set update2=1 and then submit the form.

Thanks in advance for hanging in there with me. I really appreciate your time and effort.

UR
Uncle Ron is offline   Reply With Quote
Old 01-10-2003, 05:32 PM   PM User | #2
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
Please bear in mind that lots of people look at this. I'm looking at it now, and have no idea what you're talking about.

Can you give some context - what original thread are you referring to?
brothercake is offline   Reply With Quote
Old 01-10-2003, 05:38 PM   PM User | #3
Uncle Ron
New Coder

 
Join Date: Jan 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Uncle Ron is an unknown quantity at this point
original thread was 12621, then another was started and it was 12699.
Thanks for looking

UR
Uncle Ron is offline   Reply With Quote
Old 01-10-2003, 05:47 PM   PM User | #4
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
Hey Ron, just FYI, you don't need to make multiple posts. I keep track of each post I don't respond to with my email at the house. If I don't get back to you within a day it's because, well, I'm busy.

Moving along...since you'd like to submit the form based on the changing of a SELECT, it would be important that the OPTIONs contain the data we need. What do the options look like?
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Old 01-10-2003, 05:51 PM   PM User | #5
Borgtex
Regular Coder

 
Join Date: Aug 2002
Location: Spain
Posts: 420
Thanks: 0
Thanked 0 Times in 0 Posts
Borgtex is an unknown quantity at this point
and why create a new thread, adressed to a particular user? why don't follow the original threads?
__________________
Don't resist to assimilation. Billions of Borgs can't be wrong!
Borgtex is offline   Reply With Quote
Old 01-10-2003, 06:41 PM   PM User | #6
Uncle Ron
New Coder

 
Join Date: Jan 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Uncle Ron is an unknown quantity at this point
Thank-you one and all. I know I'm confusing everyone, but it's just a symptom of my own confusion. Please accept my apologies. I really do appreciate the help and I'll try to be better about sticking with one thread.

OK, to answer beetle, here is the <SELECT> with <OPTION>, keep in mind that EVERY page served from this site is dynamically generated with PERL. The script finds the right database and loads a hash that is used as the <OPTION> parameters.

like so:

<FORM method="post" action="https://$base/$root/$program?mstrinput=$mstrinput">
<TR><TD class=md align=right width=50%>Select a Group:&nbsp;
<TD><SELECT name=group onChange="this.form.submit()">
<OPTION>$group # SET NULL FOR FIRST OPTION
PrintTag
$dir = "$path/$pwid/groups";
ReadDir();
foreach $group(sort keys %groups)
{print"<OPTION>$group"; # SET DEFAULT VALUE TO GROUP NAME
}
print<<"PrintTag";


The {print"<OPTION>$group";} correctly places the GROUP's and the onChange="this.form.submit()" really does submit the correct group name.

Unfortunately the <FORM> has three submit buttons. When you actually 'click' on a button, that button is initialized and it's value passed to the script. The other two buttons either remain null or are not passed at all (I'm not sure which is the case.) In either case, I'd like the onChange to initialize update2 button to 1.

I have found that variables within the <INPUT> tag are only included in the submission of a form when they are EXPLICITLY selected or clicked. I'm just thinking, can JavaScript really change a variable that is within a <INPUT> tag, or do I need to add the proper variable as part of the <OPTION> tag. Sort of like this:

<OPTION value=$update2|$group>$group ??

UR
Uncle Ron is offline   Reply With Quote
Old 01-10-2003, 07:28 PM   PM User | #7
Uncle Ron
New Coder

 
Join Date: Jan 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Uncle Ron is an unknown quantity at this point
Smile onChange problems

Thank-you all, especially beetle.

The onChange is doing what I need it to do. I tried the idea I had in my last message. It works just fine. In fact it works GREAT.

I'd still be interested in knowing if JavaScript is capable of initializing a variable that belongs to a <INPUT type=submit> tag.

My solution, suggested by beetle that the <OPTION> needed to have all the information makes me think that the onChange only submits the form and doesn't submit anything within the <INPUT type=submit> tag, but I'm not really sure that's true.

Again thank-you all for your help. I'ts been a lot of fun.


a very happy Uncle Ron
Uncle Ron is offline   Reply With Quote
Old 01-10-2003, 08:39 PM   PM User | #8
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
Well, this could be done.
Code:
<script type="text/javascript">
function doSubmit( elem )
{
    var f = this.form;
    var o = this.options[this.selectedIndex];
    var values = o.value.split('|');
    o.value = values[0];
    f.elements[values[1]].value = values[2];
    f.submit();    
}
</script>

<select onchange="doSubmit( this );">
<option value="group1|update2|1">Group 1</option>
<!-- other options -->
</select>
This function does three things

1) Populates 'update2' with a value of '1'
2) Populates the selected option with a value of 'group1'
3) submits the form

Are we getting warm?
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:13 AM.


Advertisement
Log in to turn off these ads.