Jump to content

Need help with form

- - - - -

  • Please log in to reply
5 replies to this topic

#1
ethikz

ethikz

    Programmer

  • Members
  • PipPipPipPip
  • 112 posts
I have searched and can't find anything to help me. I want to make it so if the element "satisfaction" is either x or y then it will display element "testimonial" if not then keep element "testimonial" hidden. This is what I have so far but it isn't working. Any help would be greatly appreciated

<form id="feedback-form" method="post" action="contactvalidate.php" action="javascript:alert('success!');">


			<label>Name</label><input class="required inpt" type="text" name="name" value="" /><br />

			<label>Company Name</label><input class="required inpt" type="text" name="companyname" value="" /><br />

			<label>E-Mail</label><input class="required inpt" type="text" name="email" value="" /><br />

			<label>Phone Number</label><input class="required inpt" type="text" name="phone" value="" /><br />

			<label style="margin-bottom:10px">Have you ordered from us?</label><input class="radio" type="radio" name="order" value="Yes" />Yes <input class="radio" type="radio" name="order" value="No" />No<br />

			<label>Your level of satisfaction</label>

				<select name="satisfaction" id="satisfaction" class="select">

					<option value="">--Select One--</option>

					<option value="Very Satisfied">Very Satisfied</option>

					<option value="Moderately Please">Moderately Pleased</option>

					<option value="Somewhat Dissatisfied">Somewhat Dissatisfied</option>

					<option value="Very Dissatisfied">Very Dissatisfied</option>

				</select><br />

			<!--  <input class="required inpt" type="text" name="subject" value="" /> --><br />

			<label>Comments</label><textarea class="textbox" name="message" rows="6" cols="30"></textarea><br />

			<label>Is it okay for us to use your comments as a testimonial in our marketing?</label><input class="radio" type="radio" name="testimonial" value="Yes" />Yes <input class="radio" type="radio" name="testimonial" value="No" />No<br />

			<label id="load"></label><input name="submit" type="image" class="btn" src="images/submit.gif" value="Send" />


		</form>

<!--end #footer--></div>

      

<script type="text/javascript">

function getIndex()

{

  var x=document.getElementById("satisfaction");

  if (x.selectedIndex == 'Very Satisfied' , 'Moderately Please');

   {

    $('#testimonial').show();

   }

  else

   {

    $('#testimonial').hide();

   }

}

</script>



#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
x.selectedIndex gives you an index. Not the option or anything, just the number of the selected option. You'll need something like
var index = x.selectedIndex;
 ...  x.options[index].value == 'Very Satisfied' ...


#3
ethikz

ethikz

    Programmer

  • Members
  • PipPipPipPip
  • 112 posts
Hmm I tried that but the conditional radio box is still showing up.

#4
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Maybe cause
[COLOR=#333333][FONT=monospace]$('#testimonial')[/FONT][/COLOR]
Will select stuff with class "testimonial"

#5
ethikz

ethikz

    Programmer

  • Members
  • PipPipPipPip
  • 112 posts
Hmm I thought I needed that if I wanted the checkbox to show if someone had Very Satisfied or Moderately Pleased and if one of those two aren't selected then it needs to stay hidden

#6
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Read my previous post again...




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users