Jump to content

drop down menu question


imarockstar

Recommended Posts

hey guys im trying to insert some data from a drop down menu .. here is my code ..

 

 

echo "Please select a Sub Category<br>";

 

echo "

<select name='subcat' size='1'>

<option value='Ex Girlfriend'>Ex Girlfriend</option>

<option value='Asian'>Asian</option>

<option value='Sex'>Sex</option>

<option value='Party'>Party</option>

<option value='Fan Sign'>Fan Sign</option>

<option value='Oral'>Oral</option>

<option value='Teen'>Teen</option>

<option value='Tease'>Tease</option>

<option value='Girl on Girl'>Girl on Girl</option>

<option value='Cum Bath'>Cum Bath</option>

<option value='Girl Next Door'>Girl Next Door</option>

<option value='Cool Site'>Cool Site</option>

<option value='Misc'>Misc</option>

<option value='Myspace'>Myspace</option>

<option value='Webcam girl'>Webcam Girl</option>

</select>

<br><br>

";

 

 

when i submit it ..it puts the NAME "cat" in the database, im trying to get it to put the VALUE of the option in .. .what am I doing wrong.

 

ps .. yes its a porno site ..haha

Link to comment
Share on other sites

if(isset($_POST['submit']))

 

{

 

  $url=$_POST['url'];

 

  $button=$_POST['button'];

 

  if(strlen($url)<1)

 

  {

 

      print "You did not enter a URL.";

 

  }

 

  else if(strlen($button)<1)

 

  {

 

      print "You did not enter a button.";

 

  }

 

  else

 

  {

 

    $insertbutton="INSERT into  TABLENAME (url, image, cat, subcat) values('$url','$button','$cat','$subcat')";

 

    mysql_query($insertbutton) or die(mysql_error());

 

    print "Button added into system.";

 

  }

 

 

 

}

Link to comment
Share on other sites

here is the whole code

 

<?php

 

 

 

if(isset($_POST['submit']))

 

{

 

  $url=$_POST['url'];

 

  $button=$_POST['button'];

 

  if(strlen($url)<1)

 

  {

 

      print "You did not enter a URL.";

 

  }

 

  else if(strlen($button)<1)

 

  {

 

      print "You did not enter a button.";

 

  }

 

  else

 

  {

 

    $insertbutton="INSERT into  TABLENAME (url, image, cat, subcat) values('$url','$button','$cat','$subcat')";

 

    mysql_query($insertbutton) or die(mysql_error());

 

    print "Button added into system.";

 

  }

 

 

 

}

 

else

 

{

 

    print "<form action='addlink.php' method='post'>";

 

    print "URL(include http://):<br>";

 

    print "<input type='text' name='url' size='20'><br>";

 

    print "Image(button URL):<br>";

 

    print "<input type='text' name='button' size='20'><br>";

 

echo "Pleae select a Category<br>";

 

echo "

<select name='cat' size='1'>

<option value='Affiliate'>Affiliate</option>

<option value='Friend'>Friend</option>

</select>

<br><br>

";

 

echo "Please select a Sub Category<br>";

 

echo "

<select name='subcat' size='1'>

<option value='Ex Girlfriend'>Ex Girlfriend</option>

<option value='Asian'>Asian</option>

<option value='Sex'>Sex</option>

<option value='Party'>Party</option>

<option value='Fan Sign'>Fan Sign</option>

<option value='Oral'>Oral</option>

<option value='Teen'>Teen</option>

<option value='Tease'>Tease</option>

<option value='Girl on Girl'>Girl on Girl</option>

<option value='Cum Bath'>Cum Bath</option>

<option value='Girl Next Door'>Girl Next Door</option>

<option value='Cool Site'>Cool Site</option>

<option value='Misc'>Misc</option>

<option value='Myspace'>Myspace</option>

<option value='Webcam girl'>Webcam Girl</option>

</select>

<br><br>

";

   

 

    print "<input type='submit' name='submit' value='submit'></form>";

 

 

 

}

 

?>

 

to answer your above question ... i thought the values would come from the VALUE in the drop down ???

Link to comment
Share on other sites

First of all you need to give name to the form and then using the java script get the values of cat and subcat as given below

 

$cat=document.formname.cat.options[document.formname.cat.selectedIndex].value

$sub=document.formname.sub.options[document.formname.sub.selectedIndex].value

Link to comment
Share on other sites

First of all you need to give name to the form and then using the java script get the values of cat and subcat as given below

 

$cat=document.formname.cat.options[document.formname.cat.selectedIndex].value

$sub=document.formname.sub.options[document.formname.sub.selectedIndex].value

A server side variable can not be assigned a client side javascript value.

Link to comment
Share on other sites

 

A server side variable can not be assigned a client side javascript value.

then how to get the cat and subcat values using server side scripting assume that all the HTML tags are embedded in print statement.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.