PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #16  
Old November 16th, 2009, 11:59 AM
AnonG AnonG is offline
Contributing User
Click here for more information.
 
Join Date: Jun 2009
Posts: 71 AnonG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 3 h 55 m 34 sec
Reputation Power: 1
You mean like this?

Code:
   function x_y(id1, id2, id3, id4)
   {
      var queryString = "x_y.php?";
      alert(queryString);

      var ele = document.getElementById(id1);
      if(ele && ele.value != 0)
      {
         queryString = queryString+""+id1+"="+ele.value;
      }

      ele = document.getElementById(id2);
      if(ele && ele.value != 0)
      {
         queryString = queryString+"&"+id2+"="+ele.value;
      }

      ele = document.getElementById(id3);
      if(ele && ele.value != 0)
      {
         queryString = queryString+"&"+id3+"="+ele.value;
      }

      ele = document.getElementById(id4);
      if(ele && ele.value != 0)
      {
         queryString = queryString+"&"+id4+"="+ele.value;
      }

      document.location = queryString;
   }


No error messages and same thing happens, it just reloads the page but adds ? at the end. Tried it again with xy.php and it works perfectly. Frustrating!

Reply With Quote
  #17  
Old November 16th, 2009, 01:41 PM
IAmALlama IAmALlama is offline
Me
Click here for more information. Click here for more information
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 2,067 IAmALlama User rank is Private First Class (20 - 50 Reputation Level)IAmALlama User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 6 Days 6 h 55 m 2 sec
Reputation Power: 5
try putting more of the url. like the absolute path. /folder/x_y.php or the full url http://localhost/folder/x_y.php

when I took the original script I wrote and put it in a file called x_y.php everything worked fine. I also tried taking off the filename (take off "x_y.php"+) so it would redirect to just queryString it worked fine also.

Last edited by IAmALlama : November 16th, 2009 at 01:54 PM.

Reply With Quote
  #18  
Old November 16th, 2009, 01:46 PM
AnonG AnonG is offline
Contributing User
Click here for more information.
 
Join Date: Jun 2009
Posts: 71 AnonG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 3 h 55 m 34 sec
Reputation Power: 1
Tried both absolute path and and full url, nothing changed.

When I removed my file and left queryString = "?" it still redirected to x_y.php?.

Tried it again with xy.php and it works.

Reply With Quote
  #19  
Old November 16th, 2009, 01:56 PM
IAmALlama IAmALlama is offline
Me
Click here for more information. Click here for more information
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 2,067 IAmALlama User rank is Private First Class (20 - 50 Reputation Level)IAmALlama User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 6 Days 6 h 55 m 2 sec
Reputation Power: 5
and did you alert() the querystring to make sure there wasn't something wrong elsewhere?

Code:
      var newURL = "x_y.php" + queryString;
      alert(newURL);
      document.location = newURL;

Reply With Quote
  #20  
Old November 16th, 2009, 02:55 PM
AnonG AnonG is offline
Contributing User
Click here for more information.
 
Join Date: Jun 2009
Posts: 71 AnonG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 3 h 55 m 34 sec
Reputation Power: 1
Yup tried that before. Tried your example now aswell. Same thing. Refreshes page and adds ? behind .php.

I have no idea why the script wouldn't allow underline in file names.

Edit: Solved, I used a copy of the same function in the same page and both had same Id's, that's why it didn't work. Changed it and now it works perfectly.

Thanks for the help!

Last edited by AnonG : November 16th, 2009 at 09:59 PM.

Reply With Quote
  #21  
Old November 17th, 2009, 08:55 AM
MatthewJ MatthewJ is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: May 2007
Location: Davenport, Iowa
Posts: 631 MatthewJ User rank is Private First Class (20 - 50 Reputation Level)MatthewJ User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 21 h 34 m 23 sec
Reputation Power: 3
As an aside... if you're going to use PHP_SELF for a form action, you should wrap it with htmlentities to avoid XSS attacks.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Form + javascript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 9 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek