SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2000
    Location
    England
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any way to do this?

    I have a text field asking for a search term and a drop down menu. The drop down menu will be say vbulletin forums and links directory. What i want is for the script to submit to search.php if forums are selected and search.cgi if links is selected. Does this make sense? There will also be hidden variables, it would be better if they could be associated with either one or other of the actions but it is not essential.

    Any ideas on how to do this or do i need to have an intermediate script?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Chris this should get you going:
    Code:
    <html>
    <head>
    	<title>Untitled</title>
    <script language="JavaScript">
    <!--
    	function create_action() {
    
    		for (var i =0; i < selecter.options.length; i++) {
    			if (selecter.options[i].selected == true) {
    				var peeper = selecter.options[i].value;
    				}
    			}
    		if (peeper == 'forums') {
    			document.form1.action = 'search.php';
    			}
    		else {
    			document.form1.action = 'search.cgi';
    			}
    
    		document.form1.submit();
    		}
    		
    		
    //-->
    </script>
    
    </head>
    
    <body>
    <form name="form1">
    <select name="loc">
    <option value="forums">Forums
    <option value="links">Links
    </select>
    <input type="submit" nbame="submit" value="Submit" onClick="create_action();">
    </form>
    
    <script language="JavaScript">
    <!--
    var selecter = document.form1.loc;
    //-->
    </script>
    
    </body>
    </html>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Evangelist
    Join Date
    Feb 2000
    Location
    England
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you so much for that but i am having some problems:

    first i get this javascript error:

    line: 19
    char: 3
    Object does not support this property or method.

    It still seems to work though.

    but...

    if i add a hidden variable to the form, instead of going to the script like it should it does c:// sort of thing, ie the bit from the script is lost. any ideas on that?

    lastly, how would i get the method="GET" into the form?

    sorry for so many questions, but thanks for all the help so far.

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change
    Code:
    <form name="form1">
    to

    Code:
    <form name="form1" action="" method="GET">
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •