Closed Thread Icon

Topic awaiting preservation: Javascript help (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=25151" title="Pages that link to Topic awaiting preservation: Javascript help (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Javascript help <span class="small">(Page 1 of 1)</span>\

 
shay005
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Mar 2005

posted posted 03-02-2005 19:57

Hi. I'm trying to use a drop down menu to choose a form which is hidden on page load. I can't make the forms visible once they are selected though. It keep trying to call an outter link. Yes I am new to javascript!
The forms are to be email submitted when completed. I have the forms all set to be emailed when submitted but I cannot get them to appear when called for the drop down menu.

(Edited by shay005 on 03-02-2005 19:59)

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 03-02-2005 20:10

Hello and welcome in the Asylum,

Would you mind to provide a link to your test page and to clarify what your goal and problem are. Thanks.
The I asked a question about a JavaScript problem in the DHTML forum, but no one is replying. How can I get people to help me? includes some usefull advices to ask correctly a technical question.

shay005
Obsessive-Compulsive (I) Inmate

From:
Insane since: Mar 2005

posted posted 03-02-2005 20:33

Okay but please remember I am very new to this! Thanks for the welcome!

The test page is http://www2.esc.edu/sbrossoit/form/webform2.html

My problem. There are 2 hidden forms on this page that when filled out are going to be emailed.
When called from the drop down menu the selected form is suppose to become visible.
When I try to call them from the drop down menu the page tries to access another page that does not exist.

I know the coding is probably off but I only started javascript 2 days ago.

kuckus
Paranoid (IV) Mad Librarian

From: Glienicke
Insane since: Dec 2001

posted posted 03-02-2005 20:38

Hi Shay! Is this what you're looking for?

http://kussatz.com/asylum/shay.html

shay005
Nervous Wreck (II) Inmate

From:
Insane since: Mar 2005

posted posted 03-02-2005 20:52

I'm trying it now. Will let you know! Thank you kuckus!

kuckus
Paranoid (IV) Mad Librarian

From: Glienicke
Insane since: Dec 2001

posted posted 03-02-2005 21:11

I just updated the page as there was a typo in my hideAll function - should be formNumber<=3 in the for loop. Sorry

shay005
Nervous Wreck (II) Inmate

From:
Insane since: Mar 2005

posted posted 03-02-2005 21:20

Okay I changed the coding. The forms are visible at all times,which I want them to be only visible when called, and the menu does not call either form. Windows is telling me that line 19 is missing an object. It's kinda long but here is my code, do you see the problem?

<script type="text/javascript">

if (document.all && !document.getElementById)
document.getElementById = function(id)
{
return document.all[id];
}
function hideAll()
{
for (formNumber=1; formNumber<=2; formNumber++)
document.getElementById("form"+formNumber).style.display = 'none';
}

function show(formNumber)
{
document.getElementById("form"+formNumber).style.display = 'block';
}
</script>
</head>

<body>


<h1 align="center">Forms</h1>


<p><b>Please Choose a form below</b></p>
<br />


<form action"">
<select name="forms" onchange="hideAll();

show(this.form.forms.options[this.form.forms.options.selectedIndex].value);">
<option value="">Select a form</option>
<option value="1">Feedback</option>
<option value="2">Help Request</option>
</select>
</form>


<br />
<br />

<!-- 1 -->
<form id="1" action="http://www2.esc.edu/jstoner/form-to-email.php" method="post">
<input type="hidden" name="ToAddress" value="" />
<input type="hidden" name="CCAddress" value="" />
<input type="hidden" name="Subject" value=""/>
<fieldset>
Email:<br /><input type="text" name="FromAddress" /><br />
Name:<br /><input type="text" name="Name" /><br />
Address:<br /><input type="text" name="Street address" /><br />
Address 2:<br /><input type="text" name="address 2" " /><br />
City:<br /><input type="text" name="city" /><br />
State:<br /><input type="text" name="state" /><br />
Zip code:<br /><input type="text" name="zip code" /><br />
Country:<br /><input type="text" name="Country" /><br />
Rate my site from 1 to 5<br />
1 = :0( <br />
5 = :0) <br />
<input type="radio" name="rating" value="1" />1<br />
<input type="radio" name="rating" value="2" />2<br />
<input type="radio" name="rating" value="3" />3<br />
<input type="radio" name="rating" value="4" />4<br />
<input type="radio" name="rating" value="5" " />5<br />
Comments:<br />
<textarea name="Comments" rows="10" cols="25" ></textarea><br />
<input type="submit" value="Submit" style="margin-top: 20px" />
<input type="reset" value="Reset Form" style="margin-top: 20px" />
</fieldset>
</form>


<br /><br />

<!-- 2 -->
<form id="2" action="http://www2.esc.edu/jstoner/form-to-email.php" method="post">
<input type="hidden" name="ToAddress" value="" />
<input type="hidden" name="CCAddress" value="" />
<input type="hidden" name="Subject" value="" />
<fieldset>
Email:<br /><input type="text" name="FromAddress" /><br />
Name:<br /><input type="text" name="Name" /><br />
Address:<br /><input type="text" name="Street address" /><br />
Address 2:<br /><input type="text" name="address 2" /><br />
City:<br /><input type="text" name="city" /><br />
State:<br /><input type="text" name="state" /><br />
Zip code:<br /><input type="text" name="zip code" /><br />
Country:<br /><input type="text" name="Country" /><br />
Phone:<br /><input type="text" name="Number" /><br />
Would you like to be contacted by email or phone?<br />
<input type="checkbox" name="contact" value="email" />Email<br />
<input type="checkbox" name="contact" value="phone" />Phone<br /><br />
Give a explaination of your problem:<br />
<textarea name="problem" rows="15" cols="30"></textarea><br />
<input type="submit" value="Submit" style="margin-top: 20px" />
<input type="reset" value="Reset Form" style="margin-top: 20px" />
</fieldset>
</form>

kuckus
Paranoid (IV) Mad Librarian

From: Glienicke
Insane since: Dec 2001

posted posted 03-02-2005 21:41

Yup - to have the forms appear hidden (umm...?) when the page loads, you'll have to use some CSS similar to what I have in the form tags on my page (style="display: none;").

The 'missing object' errors are caused by your naming of the form IDs, I'd guess. The JS functions look for IDs "form1" and "form2", but yours are "1" and "2" only.

shay005
Nervous Wreck (II) Inmate

From: Ny
Insane since: Mar 2005

posted posted 03-02-2005 21:54

Hi kuckus. I changed the names to form1 and form2. What I meant by hidden is that I want it so that the forms don't show when the page loads. So that the only thing on the page is the drop down to select a form. Any ideas on that?

~Shay

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 03-02-2005 22:02
quote:
So that the only thing on the page is the drop down to select a form. Any ideas on that?

Use the CSS to set the visibility of your forms to "hidden", or the display property to "none". Then, the 2 functions of kuckus should work like a charm.

shay005
Nervous Wreck (II) Inmate

From: Ny
Insane since: Mar 2005

posted posted 03-02-2005 22:20

Thanks that does work. One problem left..I need the drop down menu to show on the page, considering that how would I hide the 2 forms until they are called? My drop down menu is a form so the css is hiding it as well.

~Shay

kuckus
Paranoid (IV) Mad Librarian

From: Glienicke
Insane since: Dec 2001

posted posted 03-02-2005 22:23

shay: For that you'll need the style="display: none;" attribute in your form tags, i.e.

<form id="form1" ...... style="display: none;">


kuckus

shay005
Nervous Wreck (II) Inmate

From: Ny
Insane since: Mar 2005

posted posted 03-02-2005 22:31

You guys are so great! Thanks for the help I so appreciate it. I will be using these forums for help more often! Thanks again!

~Shay

« BackwardsOnwards »

Show Forum Drop Down Menu