I am nearly finished a web application for job postings. I would like to construct a mailto link that picks up the job title from my database. Unfortunately, there are spaces in the jobtitle and the mailto link cuts off at the first space. In my display all records page, I would like to replace the spaces with %20 but have had no success with any attempts.
The section of code I am dealing with looks like this:
Dim strEmail
strEmail = Replace(rsJobpost("jobtitle"), " ", "%20")
?
Although, spaces in the href of an anchor tag should not cause trouble. What is the output?
Regards.
blodefood
06-21-2005, 09:30 AM
Have you tried:
Dim strEmail
strEmail = Replace(rsJobpost("jobtitle"), " ", "%20")
?
Although, spaces in the href of an anchor tag should not cause trouble. What is the output?
Regards.
I get an error or it stops at the end of the colon after the word Application. The mailto link still works but the subject line still does not pickup the job title.
After looking at the code all day yesterday, I noticed too that there is no provision for a double quote " at the end of the ahref tag. I tried to put that in to see if it would resolve the space problem, but I kept getting either nothing or an error about mismatch.
Thanks, I did try it and wracked my brains (as well as the brains of others on the forums) and it still didn't work. :mad: While the applyto field is used twice in the mailto link and appears correctly both times, it seems the jobtitle field lost its data the second time around on the page. :confused: I used it once further up the code. My workaround was adding a second jobtitle field called joblink. :cool: This is the field now used instead of jobtitle in the above code. I added the field to the add form as well with a javascript to copy automatically whatever is entered into the jobtitle field so the user doesn't have to retype it. I hope my HR manager is pleased!
Meantime, if I find a better way to do this, I will implement it.
- blodefood :D
mjcolli
06-21-2005, 03:51 PM
Server.UrlEncode(rsJobpost("jobtitle")))
buntine
06-21-2005, 04:18 PM
Server.UrlEncode(rsJobpost("jobtitle")))
Good point.
Can you post your full code?
Regards.
mjcolli
06-21-2005, 04:26 PM
Well, I don't have any full code, per se. That's just what I use when I need to put something in the query string. For instance:
Response.write(strWhatever)
this would write: http://www.yahoo.com?myName=Michael%20Collins
I tried this too and it didn't work. I am sure it would work if I had a static URL as you have shown above.
Here's my code. I've included the entire table structure so you can see why I put the table stuff in there. If we are able to solve the problem I hope this can help someone else. If not, at least I still have my workaround.
- blodefood
<table width="660" border="0" cellspacing="0" cellpadding="5">
<tr>
<td colspan="2"><img src="FNHRheader650x98.jpg" width="650" height="98"></td>
</tr>
<tr bgcolor="#007A62">
<td width="258"><div align="center"><font color="#FFFFFF" size="5" face="Verdana, Arial, Helvetica, sans-serif"><strong>Job
Postings</strong></font></div></td>
<td width="382" valign="middle"><!--#include file="updateddate.inc"--> </td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Click the
blue links to open the Job Description</font></td>
</tr>
</table>
<table border="1" cellpadding="2" cellspacing="2" width="800" bgcolor="#FFFFCC">
<tr>
<th><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Job Title<br>
<font size="1"> (number of positions in brackets) </font> </font></th>
<th><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Apply To:</font></th>
<th><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Location</font></th>
<th><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> Date Posted </font></th>
<th><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> Date Closed </font></th>
</tr>
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsJobpost 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("jobpost.mdb")
'Create an ADO recordset object
Set rsJobpost = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT jobtable.* FROM jobtable;"
'Open the recordset with the SQL query
rsJobpost.Open strSQL, adoCon
'Loop through the recordset
Do While not rsJobpost.EOF
'Move to the next record in the recordset
rsJobpost.MoveNext
Loop
'Reset server objects
rsJobpost.Close
Set rsJobpost = Nothing
Set adoCon = Nothing
%>
</table>
mjcolli
06-21-2005, 05:15 PM
it's not a dynamic link thing. It's just a string thing.
Response.Write ("</font></td><td valign='top'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>")
Response.Write "<a href=""mailto:"
Response.Write (rsJobpost("applyto"))
Response.Write("&subject=Application:" & rsJobpost("jobtitle"))
Response.Write (""">")
Response.Write (rsJobpost("applyto"))
Response.Write ("</a><br>")
Should be:
Response.Write ("</font></td><td valign='top'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>")
Response.Write "<a href=""mailto:"
Response.Write (rsJobpost("applyto"))
Response.Write("&subject=Application:" & server.URLEncode(rsJobpost("jobtitle")))
Response.Write (""">")
Response.Write (rsJobpost("applyto"))
Response.Write ("</a><br>")
You have tried this, and it didn't work?
blodefood
06-21-2005, 05:25 PM
it's not a dynamic link thing. It's just a string thing.
Response.Write ("</font></td><td valign='top'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>")
Response.Write "<a href=""mailto:"
Response.Write (rsJobpost("applyto"))
Response.Write("&subject=Application:" & rsJobpost("jobtitle"))
Response.Write (""">")
Response.Write (rsJobpost("applyto"))
Response.Write ("</a><br>")
Should be:
Response.Write ("</font></td><td valign='top'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>")
Response.Write "<a href=""mailto:"
Response.Write (rsJobpost("applyto"))
Response.Write("&subject=Application:" & server.URLEncode(rsJobpost("jobtitle")))
Response.Write (""">")
Response.Write (rsJobpost("applyto"))
Response.Write ("</a><br>")
You have tried this, and it didn't work?
Yup! And I got
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'URLEncode'
/test/jobpostings/displaywork.asp, line 86
- blodefood
buntine
06-21-2005, 06:29 PM
Hmm.. It looks fine. Can we see the output HTML of this page? Go to View > Source and paste it here.
Regards.
blodefood
06-22-2005, 09:35 AM
Hmm.. It looks fine. Can we see the output HTML of this page? Go to View > Source and paste it here.
Regards.
Here's the code. Note that the spaces in the links to job descriptions are picked up when the user copies the shortcut from another page and pastes it into the field. The other fields are typed in directly.
sans-serif"><strong>Job
Postings</strong></font></div></td>
<td width="382" valign="middle"><font face='Verdana' size='2' color='white'>Updated: Tuesday, June
21, 2005 17:32 ET</font> </td>
</tr>
<tr>
<td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Click the
blue links to open the Job Description</font></td>
</tr>
</table>
The problem might lie in the fact that alot of your quotes are not closed or you have not used them at all. HTML attributes should always be enclosed in quotes.
You may also need to remove (which is a single space) from the records in your database.
Regards.
webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved.