473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Cross reference URL submit to form

After browsing and crudely dusting off my JS knowledge over the past few day's I'm stumped on how to do this effectively as a lot of the parameters I've read are very outdated?

Simply I want to determine the value of the current page URL and if accurate it will then return a value that will be assigned to a form text box.

e.g. If the URLs are as such for example:

www.test.com/number1
www.test.com/number2
www.test.com/number2

Then if the user visits test.com/number2 the form will automatically populate itself with 'This is page Number 2'.

My code seems to return the string regardless of the URL, but also creates a seperate form, it does not post to the form which has the correctly assigned ID and NAME.

If any one can help or point me in the right direction it would be really really help thank you.


Expand|Select|Wrap|Line Numbers
  1. var prod_name = parent.location.href
  2. {
  3. if (prod_name = "http://www.test.com/number2")
  4.     {document.write("<input type='text' name='Test_Name' id='Test_Name' value='This is page number 2'>");
  5.       }
  6. }
  7.  


UPDATE: I have revised the code to look something more like below, but it is still returning the web value if any of the characters are present i.e. it will return 'true' if even 'www.' was present.

Is there a specific way determine the entire string of the URL for the reference?

Expand|Select|Wrap|Line Numbers
  1. var NAME = parent.location.href
  2.  
  3. if (NAME = "http://www.test.com/page1")
  4.       {
  5.  
  6.       var name_element = document.forms["formname"].elements["pagename"];
  7.       //alert("name_element = " + name_element);
  8.  
  9.       name_element.value = "THIS IS PAGE ONE";
  10.       if (pagename.length >= 5)
  11.          {        
  12.          name_element.readOnly=true
  13.          }
  14.  
  15.      else
  16.  
  17.      name_element.value = "Enter PAGE";
  18.       if (prod_name.length >= 10)
  19.          {         
  20.          name_element.readOnly=false
  21.          }
  22.       }
  23.  
Jan 10 '11 #1
0 1268

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mark Michel | last post by:
Hi. I have made an html form which I would like to send by e-mail. When the recipient receives the e-mail form, I would like them to be able to fill it out and click the Submit button which will...
2
by: Matt | last post by:
The problem is I have 3 buttons that need to submit the form to different URL. My approach is to declare <input type="submit"> rather than <input type="button">. And put the following in the...
2
by: Terence Parker | last post by:
How does one go about submitting a form with a link - but submitting it to a new window AND to a page different to that described within the action="" option of the <form> tag? Say, for example,...
3
by: jeff | last post by:
Hello, I have a form that submits it's values to a pop-up window. I've simplied the code: <form name="formname" action="action.php" target="windowName" method="post" onsubmit="window.open('',...
6
by: CJM | last post by:
Can somebody clarify if/how/when a simple form is submitted when the <Enter> key is pressed? As I understood it, if you have a form with a single submit button, if enter is pressed, the form...
1
by: Matt | last post by:
The problem is I have 3 buttons that need to submit the form to different URL. My approach is to declare <input type="submit"> rather than <input type="button">. And put the following in the...
3
by: maffonso | last post by:
Hi guys, I have built a cross reference query (columns is year). I would like to change the caption and adjust others things. The best way would be to wrap the query in a form, but soon 2007 will...
16
MitchR
by: MitchR | last post by:
Hi All; I have a form that contains a textbox control called CPUServicetag (Serial number). My users enter in the CPUServicetag manually. My question is this ... How do I go about creating an...
1
misscrf
by: misscrf | last post by:
I have a table that acts as a cross reference to related records. No we can't get different data, no we have no control over what we have, we just need to be able to manage what we have been given....
4
by: nospam | last post by:
I have a table that acts as a cross reference to related records. No we can't get different data, no we have no control over what we have, we just need to be able to manage what we have been...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.