# If/then with forms quandry

**URL:** <https://forum.kirupa.com/t/if-then-with-forms-quandry/7592>\
**Category:** Uncategorized\
**Created:** [November 4, 2002, 12:45am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592 "2002-11-04T00:45:58Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![poedog99](https://avatars.discourse-cdn.com/v4/letter/p/58f4c7/32.png) [@poedog99](https://forum.kirupa.com/u/poedog99)\
**Post date:** [November 4, 2002, 12:45am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/1 "2002-11-04T00:45:58Z")

</div>

Hey there-new to this board,  
I am fairly new to JS, I hope someone could help me with this supposedly ‘simple’ task!

The problem lies with this snippet of code:  
(if you want to see the entire html page, you can view it at:  
[http://www.perfectlygrand.com/mod1\_quiz1b.html](http://www.perfectlygrand.com/mod1_quiz1b.html))

```php
<input type="button" name="Button" value="Submit" onClick="if (value == "b") {MM_openBrWindow('1right.html','','width=230,height=150')) else {MM_openBrWindow ('1wrong.html','','width=230,height=150')}">

```

What I am trying to achieve is a button that, when pressed will read which radio button the person has pressed and then will launch a relevant pop-up window depending on whether they pressed the ‘b’ radio button or if they’ve pressed something other than b(which will then popup with a different window).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 4, 2002, 4:28am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/2 "2002-11-04T04:28:31Z")

</div>

Hey poe,

I didn’t fix your problem (although I know how), but instead I whipped up a quick .html file you can check out.

I commented everything in the code so it could help you understand what I did.

I hope it helps. If you have any questions, just ask.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 4, 2002, 6:25am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/3 "2002-11-04T06:25:48Z")

</div>

Thanks LIB, I know my Fiance will appreciate that. 🙂

yes Poe is Laurie. 🙂 (well, actually he’s our dog, but you know what I mean. 🙂 )

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 4, 2002, 6:28am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/4 "2002-11-04T06:28:14Z")

</div>

oh… :beam:

She is welcome. If she needs any more help she can just ask.

Oh yeah, I snooped in her source to see what else she was doing and…

she should use

```php
<B></B>

```

instead of

```php
<strong></strong>

```

Strong is a bit outdated, that is older HTML 🙂

(the B stands for bold, so its easy to remember that way too)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 4, 2002, 6:28am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/5 "2002-11-04T06:28:59Z")

</div>

hmm… looks about like what she was discribing. Should help anyway.

Question though… as this works, all the answers are stored on the html page that contains the questions. Is there an easy way, without using CGI to contain those answers in a separate file, elsewhere on the server?

Laurie didn’t ask, I’m just interested in that answer

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 4, 2002, 6:32am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/6 "2002-11-04T06:32:10Z")

</div>

She could copy and paste the content between the script tags (she can delete the script tags), put it in an external .js file (can save one of these in notepad, just save as “All Files” and put the extension .js at the end). And then insert the code into the page like this…

```php
<script src="script.js" type="text/javascript"></script>

```

She can probably cleverly disguise the name of the .js file so people think it doesn’t have to do with the quiz thing.

When the source is viewed, the script right above will show, not the actual script that she has in the .js file.

[edit]Hey david, did you ever check out that script I sent you for dynamic pop-ups in Flash or something like that. It was a while ago, but I just saw the file on my comp and it reminded me of it [/edit]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 4, 2002, 7:08am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/7 "2002-11-04T07:08:08Z")

</div>

I probebly have not. I’ve been having difficulty getting on Flash and doing any work with it for quite some time now. Send it again, I’ll look at it, I promise. 🙂 (ps MX still isn’t working yet, so I need it in 5.0 version if possible)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 4, 2002, 7:12am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/8 "2002-11-04T07:12:27Z")

</div>

Hrmm, I believe this is the file. I think I had a friend to it for me on Flash 5, so you could open it. I don’t have the .zip file, so I hope I didn’t open it and save it again as Flash MX… :-\

I remember you wanted the page to load from your variable name or something along those lines.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 6, 2002, 2:28am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/9 "2002-11-06T02:28:43Z")

</div>

Lost in Beta,

=) =) =) =)

Thank you for your reply!

The code works like a charm,so happy-still trying to get my head around what kind of commands to use where in javascript.

Thanx for the strong tag tip-  
I’m sure you’ll see me around here plenty!  
~Laurie

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 6, 2002, 3:21am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/10 "2002-11-06T03:21:43Z")

</div>

Hey there!

its me again,  
I realized that in picking an answer to the question,you should only be able to pick one radio button. I know that when you keep the name the same throughout the buttons it allows you to do this, but since I need the names to be different on every one,(for the if/then statement to work) I can’t do this.

There must be a way!  
I think I am a lil bit confused as to what the difference is between a name and a value is.  
~Laurie

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 6, 2002, 7:03pm UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/11 "2002-11-06T19:03:39Z")

</div>

'DOH! My greatest apologies.

I checked the results directly from the name, but completely forgot to check the id (or add the id for that matter). This is actually my first time doing this so I was bound to make a mistake…lol.

Ok, I have attached a new .zip file. This one should work with only checking one item.

Please note that I added an id=“x” (x = some letter) into each of the radio button form elements. This gives each button a specified id, while keeping the same name.

Oh yeah, as for names and values…

Name = Assigns an identifier to the element.  
Value = Preassigns a value for the input element for submission to the server. Basically, the name given under value is what the server reads after you submit the form(or at least I believe that is how it goes)

I hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 6, 2002, 11:00pm UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/12 "2002-11-06T23:00:19Z")

</div>

WAIT WAIT WAIT… Don’t download that last one.

LOL, ok, so the change I made in this one is probably unnoticeable, but I uploaded it anyway.

Can you spot the difference (that is, if you downloaded the other file)? They both work either way, the second one is just slightly… optimized (???)…lol… if you could call it that.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 8, 2002, 1:17pm UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/13 "2002-11-08T13:17:57Z")

</div>

Hi Lostinbeta-  
I have not had the opportunity to download 2.0 of formtest, but have a question. In netscape communicator 4.7 the pop-ups are not working, works in 4.0 -bazaar- but if I go into the built in javascript debugger it says the first line of the javascript code does not have any properties. Do you know what this could be? The only reason I’m asking is because the clients target browser is \<g\> 4.7

Thanks for your help  
~Laurie

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 8, 2002, 5:06pm UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/14 "2002-11-08T17:06:10Z")

</div>

Hmmm, well it works in Netscape 7, that is the only version I can test it on here… so my apologies.

I am not quite sure how to fix this problem as I do not have Netscape 4.7 to test it on.

I did come up with this though… (check attachment).

What I did here was saved the first line into a variable, and then executed that variable in the if statement. Hopefully that works :-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 10, 2002, 6:44pm UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/15 "2002-11-10T18:44:36Z")

</div>

Thanx for the alt. code,  
unfortunately netscape 4.7 is not accepting that either-javascript error. Could it be that that version did not accept a certain kind of command?

Is there any other way to get the same results while changing the code?  
I’m working on this myself, but with the limited knowledge I have right now of JS it proves to be difficult.

~L

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 10, 2002, 7:20pm UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/16 "2002-11-10T19:20:52Z")

</div>

ooh!ooh!

I found out why its not working. I looked in my dreamweaver reference guide and is says that Netscape Navigator does not support the ‘id’ tag. I tried the html document that we had before we changed it to ‘id’ and it works!!!

At least I’ve found out the problem, -now I just don’t know the solution!  
I’m so psyched to have been able to _partially_ solve the problem.😛  
~L

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 10, 2002, 7:24pm UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/17 "2002-11-10T19:24:06Z")

</div>

Oh boy… without the id… I don’t think this is possible.

But never say never eh? I will give this another shot 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 7:25am UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/18 "2002-11-11T07:25:45Z")

</div>

:::sigh:::

I have tried and tried and tried and tried and tried some more, but I can’t find a way to return results based on the value instead of the ID of an item ☹

Since the ID is the actual locator of the object, the script you current has says “if this location is checked, then do this”, but without a locator, it can’t check what is checked :-\

I didn’t even know people still used that version of Netscape :-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 4:31pm UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/19 "2002-11-11T16:31:59Z")

</div>

HA!  
You would be SURPRISED at what ancient browsers corporate america is using these days  
😛  
Anyway, I decided to go about it in a different way(god knows what kinds of problems I will run into with this one):

```php

<form name="form">
                <input type="radio" name="one" value="a">
                <font size="2" face="Arial, Helvetica, sans-serif">a. 5 years 
                in prison and/or a fine of up to $125,000 </font></p>
              <p> 
                <input type="radio" name="one" value="b">
                <font size="2" face="Arial, Helvetica, sans-serif">b. 10 years 
                in prison and/or a fine of up to $250,000 </font> </p>
              <p> 
                <input type="radio" name="one" value="c">
                <font size="2" face="Arial, Helvetica, sans-serif">c. 20 years 
                in prison and/or a fine of up to $500,000</font></p>
              <p> 
                <input type="radio" name="one" value="d">
                <font size="2" face="Arial, Helvetica, sans-serif">d. None of 
                the above</font></p>
              <p><font size="2" face="Arial, Helvetica, sans-serif"> 
              <input type="Reset" name="Reset" value="Reset">
			  <input type="Button" name="Button" value="Submit" 
			  onClick="if (this.form.b.checked){ 
_____ MM_openBrWindow('1right.html','','width=230,height=150'); 
__} 
__else { 
_____ MM_openBrWindow ('1wrong.html','','width=230,height=150'); 
__} 
}">
                              </font></p></form>

```

Its not working, do I need to refer to:

```php
 
(this.form.b.checked)

```

in the header before I call out to it??

~L

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 11, 2002, 6:11pm UTC](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592/20 "2002-11-11T18:11:58Z")

</div>

Well the main problem with that is that you are defining the whole if statement on the onClick.

You need to define the if statement in a function as I did in my previous examples.

Another problem here are the \_\_ you have before your actions in your if statement.

And another is that you are using values. And from what I tried, you can’t determine what is checked by value, but instead… ID.

:-\ ☹

[Next page](https://forum.kirupa.com/t/if-then-with-forms-quandry/7592.md?page=2)
