SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2005
    west Coast New Zealand
    0 Post(s)
    0 Thread(s)

    Red face Refernce form elements using href

    Hello everyone

    I have a problem with reading data from a form element(s). Instead of using a Type=Submit, I have chosen to use a hyper-link to call a select case structure which adds, edits or deletes a record depending on the contents of the action property.

    here is a couple of lines showing two text box's in my form, directly following is the href that passes data to the select statement.

    <td><input type="text" name="Desc" id="descid" size="55" /></td> <td><input type="text" name="Units" id="Text1" size="4" /></td> </form>

    <td align=right><a href="<%= SCRIPT_NAME %>?action=add&jdate=<%= dDate %>"><img src="Web-add.bmp" alt="Add" width="63" height="25" border="0" /></a></td>

    I would like to include the values from the form elements in the action string but have so far drawn blanks.

    I have attached the full form code.

    I hope I have explained thinks ok, Thanks in advance for any help.

    Jamie Hales

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Nelson BC
    0 Post(s)
    0 Thread(s)
    You'll need to use javascript to do it like that - so browsers that don't have it (enabled) won't work.

    function proceed(sType) {
    	var sURL = "<%= SCRIPT_NAME %>?action=add&jdate=<%= dDate %>";
    	sURL += "&Desc=" + document.getElementsByName("Desc")[0].value;
    	sURL += "&Units=" + document.getElementsByName("Units")[0].value;
    	sURL += "&Type=" + sType;
    	location.href = sURL;
    	return false;
    Then call it from your links like this:
    <a href="#" onclick="proceed('add');">add</a>
    <a href="#" onclick="proceed('edit');">edit</a>
    <a href="#" onclick="proceed('delete');">delete</a>


Posting Permissions

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